How to automatically rename tmux windows to the current directory

With tmux 2.3+, the b: format modifier shows the “basename” (or “tail”) of a path.

set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'

The FORMATS section of man tmux describes other modifiers, such as #{d:} and even #{s/foo/bar/:}.


With tmux 2.2 or older, the basename shell command can be used instead.

set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#(basename "#{pane_current_path}")'

Leave a Comment