tmux: Show Current Directory in Window Status

Tmux is still my favourite terminal session manager and it has a place in my heart and dotfiles repository. A little improvement I could make to my config recently, is that it now shows me the directory the different windows are in.

There are a LOT of different people with very different opinions using tmux, so it took a bit of digging and understanding the different variables to get what I wanted.

  1. Display the current working directory (folder) in the window name
  2. Display the active window differently
  3. Display the window index
  4. Don't display the full path, but just the last segment, so in /a/b/c only the c
# display of active window
set -g window-status-current-format '#{window_index} #{b:pane_current_path}*'
# display of all other windows
set -g window-status-format '#{window_index} #{b:pane_current_path}'
#  make sure to update the window title every 5 seconds
set -g status-interval 5

which results in a display like this:

0 jonathan 1* 
# index of window 1, directory of window 1, window 2, directory of window 2, star for current window

While playing around with the status display I had to reload the config a few times with

tmux source-file ~/.tmux.conf

to see most of the changes take effect.

Thank you for reading! If you have any comments, additions or questions, please tweet or toot them at me!