Change background color of active or inactive pane in Tmux
Are there any options to control the background color of the active or inactive panes in Tmux?
It seems that tmux-2.1 (released 18 October 2015) now allows the colours of individual panes to be specified. From the changelog:
* 'select-pane' now understands '-P' to set window/pane background colours.
e.g. [from the manual] to change pane 1's foreground (text) to blue and background to red use:
select-pane -t:.1 -P 'fg=blue,bg=red'
To mimic iTerm colour scheme:
To answer the original question, I use the following lines in my ~/.tmux.conf
for setting the background/foreground colours to mimic the behaviour in iTerm:
#set inactive/active window styles
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'
# set the pane border colors
set -g pane-border-style 'fg=colour235,bg=colour238'
set -g pane-active-border-style 'fg=colour51,bg=colour236'
I hadn't seen the window-style
and window-active-style
commands before, but maybe they were available in previous tmux versions.
Also, these two lines are pretty useful for splitting panes easily:
bind | split-window -h
bind - split-window -v
EDIT: as Jamie Schembri mentions in the comments, tmux version 2.1 (at least) will now be installed with:
brew install tmux
EDIT (Oct 2017): brew now installs tmux 2.6, and the above still works.
EDIT Vim panes: If you find that the "inactive colouring" does not work with a Vim pane, it might be due to the colourscheme you are using. Try with the pablo
scheme; i.e. in the Vim pane:
:colo pablo
To make it work with your own custom Vim colourscheme, make sure that the setting for Normal
highlighting does not have ctermbg
or guibg
specified. As an example, the "inactive colouring" does not work with the murphy
colourscheme, because in murphy.vim
there is the line:
hi Normal ctermbg=Black ctermfg=lightgreen guibg=Black guifg=lightgreen
that sets ctermbg
or guibg
to Black
. However, changing this line to:
hi Normal ctermfg=lightgreen guifg=lightgreen
will make the "inactive colouring" work.
EDIT July 2019 Augusto provided a good suggestion for also changing the background colour for the line numbers. What I use in my vim colourscheme is the following:
hi Normal guifg=#e6e1de ctermfg=none gui=none
hi LineNr guifg=#e6e1de ctermfg=none gui=none
There is no option to change the background color of a pane, but there is option to set the pane-border color (style)
pane-active-border-style style
Set the pane border style for the currently active
pane. For how to specify style, see the message-command-style option.
Attributes are ignored.
pane-border-style style
Set the pane border style for paneas aside from the
active pane. For how to specify style, see the message-command-style option.
Attributes are
ignored.