I'm starting to use tmux (I'm thinking of switching from screen), but I'm having a hard time telling which pane is focused when I split a window into multiple panes. Is there a config customization or something that can highlight the focused pane a little more explicitly?
Here are the relevant settings:
pane-active-border-style fg=colour,bg=colour
Set the pane border colour for the currently active pane.
So, try adding something like this to your ~/.tmux.conf:
set-option -g pane-active-border-style fg=blue
That will set a blue border around the active pane. The pane-active-border-style bg=colour option can be used for a more visible solution, as well.
As answered in another post it is now possible in tmux 2.1 to set the colours of individual panes. Ones can use:
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'
in the ~/.tmux.conf file to show a difference between the active/inactive panes.
With Vim If you find it does not work with Vim panes, it might be down to the colourscheme you are using. First, try another colourscheme such as pablo. For further details, see the other post.
Customize status-left and use the #P character pair, which is the pane number. You will probably want to include more than just the pane number in the status bar, but here is an example of the line you would add to your ~/.tmux.conf for just the pane number:
set-option -g status-left '#P'
See the tmux man page for more character pairs: http://manpages.ubuntu.com/manpages/precise/en/man1/tmux.1.html
One Solution that works for me is to add a display-pane at the end of the hotkey for a pane switch. This displays all the pane numbers, with the current pane in a different color. You can also use <escape_key> + q to display pane numbers.
I use alt+h/j/k/l to switch between panes, and I use the following binding.
bind -n M-j select-pane -D \; display-pane
bind -n M-k select-pane -U \; display-pane
bind -n M-h select-pane -L \; display-pane
bind -n M-l select-pane -R \; display-pane
I wanted the active pane's borders to be brighter than other panes,
so I went with this (works in tmux 1.8 w/CentOS 7):
~/.tmux.conf fragment
# rgb hex codes from https://www.rapidtables.com/web/color/RGB_Color.html
set-option -g pane-active-border-fg '#33FF33' # brighter green
set-option -g pane-border-fg '#006600' # darker green
The tmux man page says hex-RGB colors will be approximated, and I find the hex codes easier to understand than remembering "colour47" (out of colour0-255) is a kind of light green (as described in How does the tmux color palette work?).
tmux man-page excerpt:
message-bg colour
Set status line message background colour, ...etc...
or a hexadecimal RGB string such as ‘#ffffff’, which chooses the closest
match from the default 256-colour set.
For tmux 3 I was able to set the following in my .tmux.conf for a subtle border indicator:
set-option -g pane-active-border-style bg=yellow
Related
Is it possible to set window color depends on the other window-option?
When a windows has synchronize-panes enabled, I don't want to accidentally press C-d, or all panes will be closed.
So what I'm trying to do is to change window color on statusline based on synchronize-panes:
(the following config doesn't work, though)
bind-key S setw synchronize-panes \; \ # toggles the option
set -w window-status-bg '#{?pane_synchronized,yellow,default}' \; \ # error: bad color
set -w window-status-current-fg '#{?pane_synchronized,yellow,default}' # error: bad color
The most possible solution I can thought of is to use if-shell, but I prefer not to fork a shell just to read option of itself, if possible.
EDIT: This if-shell solution works for me on tmux 2.7
My statusline cyan colored, if synchronize-panes is enabled, cyan becomes yellow.
bind-key S setw synchronize-panes \; \
if-shell '[ #{pane_synchronized} -eq 1 ]' \
'set -w window-status-style fg=black,bg=yellow ; set -w window-status-current-style fg=yellow,bg=black' \
'set -w window-status-style fg=black,bg=cyan ; set -w window-status-current-style fg=cyan,bg=black'
EDIT: Problem solved, my setting is now changed to this:
bind-key S setw synchronize-panes
sync_ind_colour="#{?pane_synchronized,yellow,cyan}"
set -g window-status-format "#[fg=black,bg=${sync_ind_colour}][#I#{?#{!=:#W,},:,}#W]"
set -g window-status-current-format "#[fg=${sync_ind_colour},bg=black][#I#{?#{!=:#W,},:,}#W]"
Looks a little bit scary but it's still readable.
It shouldn't be necessary to use if-shell for this. You can use conditionals in format options, but not in styles. The following minimal configuration should do what you want.
# toggle pane synchronisation mode
bind-key S setw synchronize-panes
# Variables
sync_ind_colour="#{?pane_synchronized,yellow,cyan}"
# status format
setw -g window-status-format "#[fg=black,bg=${sync_ind_colour}]#I #W"
setw -g window-status-current-format "#[fg=${sync_ind_colour},bg=black][#I #W]"
Note that I set the text of the window status to #I #W (and [#I #W] for active) as an example, but that's irrelevant to the question.
It's also not necessary to use a variable (sync_ind_colour, synchronise indicator colour), but it's simpler than defining the same conditional in both the window-status-format and the window-status-current-format variables.
I would like to give fix name different tmux pane title but whenever I move to a different directory tmux just replace pane name that I have define with something like: 0:username#namespace:~/directory which confusing. Any help?
I found the answer here
The tmux command for this is:
set-option -g allow-rename off
I'm using bind-key + , to rename my windows, but as soon as I type a command the name reverts back to the current working directory.
Is it possible to make the window name permanent?
The automatic rename function is turned on. Add the following to your .tmux.conf file (and/or run from the command line to have it take effect immediately):
set-window-option -g automatic-rename off
Per this superuser answer, I made the following change to ~/.tmux.conf:
# NO, window name keeps changing
# set -g default-terminal "screen-256color"
# YES, window name sticks
set -g default-terminal "xterm-256color"
I've been a happy tmux user for a while now but there's one behaviour that's bugging me. When I switch panes using ^b-arrow, and then immediately press arrow-up (to get a command from history, for example), the window pane switches again. I understand this can be useful if you want to move through multiple panes quickly, but for me it's a pain in the backside since I keep ending up in panes I never meant to be in.
So, is there a way to set tmux so that the ^b-arrow command only switches pane once and ignores any following arrow key presses?
That happens because the default bindings for the arrow keys are setup with bind-key -r, specifying that they may be repeated. There are two ways that you can disable this.
First, you can use set-option repeat-time 0 to disable repeating entirely. This will affect all bindings. I find that to be very annoying when resizing panes.
Secondly, you can change the bindings for the arrow keys to use bind-key without the -r option:
bind-key Up select-pane -U
bind-key Down select-pane -D
bind-key Left select-pane -L
bind-key Right select-pane -R
If you spend a lot of times navigating panes, why not set up global mappings so you don't have to use prefixes at all, e.g. bind -n C-h select-pane -L to map ctrl-h to switching left, same as Vim.
See http://robots.thoughtbot.com/seamlessly-navigate-vim-and-tmux-splits for an even better solution that also navigates across Vim windows.
Another option is to make a binding to jump to the previous pane, if you are flicking back and forth between the same two panes.
bind-key C-a last-pane
Annoying question to have to ask! In bash (or anywhere.. like when editing this question) I can do CTRL + left|right to move left left or right to different bits of whitespace. With tmux running.. this does work.. it doesn't do anything. How do you do the same thing but with tmux?
Thank you.
You can do it by binding C-Left and C-Right to "send-keys M-b" and "send-keys M-f" in your ~/.tmux.conf file like this:
bind-key -n C-Left send-keys M-b
bind-key -n C-Right send-keys M-f
You don't. bash, respectively readline, has an idea of what you typed and can therefore jump as many characters until the next "word boundary". tmux does not have this information. Also, in tmux and the ANSI code space, I would interpret "end of line" in fact as \r\e[xB (with x being the size of the window), though that did not match up with your expectation.