89

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?

OlivierBlanvillain
  • 7,701
  • 4
  • 32
  • 51
dan
  • 43,914
  • 47
  • 153
  • 254

6 Answers6

109

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.

Samir Alajmovic
  • 3,247
  • 3
  • 26
  • 28
Alan Christopher Thomas
  • 4,532
  • 2
  • 23
  • 23
  • 2
    I don't see this option on my man page, and it's not recognized by my version of tmux. – dan Feb 03 '11 at 19:00
  • @dan Ah, you know, I had to install tmux 1.4 from source because Ubuntu repositories only had version 1.3. They're pretty different, and I really recommend doing the newer one. It's a bit more flexible. – Alan Christopher Thomas Feb 04 '11 at 01:00
  • 2
    OK thanks for letting me know. Annoyingly, tmux doesn't (?) seem to have a way to show you which version you're running. – dan Feb 04 '11 at 03:49
  • 3
    @dan Haha, I noticed that too. Ironically, I think it's one of the features added in 1.4: `tmux -V`. If you're on Ubuntu or a debian-based system, you can check with `dpkg -l | grep tmux`. – Alan Christopher Thomas Feb 04 '11 at 15:39
  • 14
    This seems to be the best answer, unfortunately if you just have a single split, all it does is color the divider and it doesn't change no matter which pane is active. – Von May 16 '13 at 23:15
  • 3
    Note that this is fixed in more recent versions. It now colors only half the divider depending on which panel you are in. – Chronial Sep 03 '14 at 23:17
  • Yes, if you have only one vertical split the top half of the border is `pane-active-border-bg` while the bottom is `pane-border-bg`. – DaftWooly Jul 29 '16 at 17:43
  • 3
    Syntax has changed (ref: https://github.com/tmux/tmux/issues/1689). It would be `pane-active-border-style fg=blue` etc. It'd be great if you can edit your answer. Thank you very much. – haxpor Feb 18 '21 at 11:45
41

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.

dean.
  • 1,657
  • 1
  • 13
  • 9
  • 1
    @Solidak It might be the Vim colourscheme you are using - please see the other post for further details. – dean. Oct 12 '18 at 04:04
  • Weird that the options are "window-style" and "window-active-style" but it's referring to tmux panes, not tmux windows. – WalksB Aug 19 '20 at 04:26
15

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

Alan Christopher Thomas
  • 4,532
  • 2
  • 23
  • 23
  • 1
    Ah, just realized you're going for a highlight on the focused pane, more so than just a status indicator. Hopefully this is helpful for now. Sorry for misreading the question. – Alan Christopher Thomas Feb 03 '11 at 18:07
7

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  
0

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.
Community
  • 1
  • 1
jgreve
  • 1,225
  • 12
  • 17
0

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
Sam Berry
  • 7,394
  • 6
  • 40
  • 58