I'm trying to set my tmux window's title to be the current directory that I am in. Now pane_current_path is perfect for this, but it prints the full path in my machine.

Is it possible to run pane_current_path though some formatting and only print out the current directory?

Currently using it like this

setw -g window-status-current-format "#{pane_current_path}"
setw -g window-status-format "#{pane_current_path}"

2 Answers 2


Tmux man page, under FORMATS section says:

The b: and d: prefixes are basename(3) and dirname(3) of the variable respectively.

Following option should effectively change window's title to basename of current directory:

setw -g automatic-rename-format "#{b:pane_current_path}"


(Inspired by https://stackoverflow.com/a/32426739 and https://stackoverflow.com/a/9757133)

This can be done if your shell has a 'precmd' hook (bash and zsh do); this hook would be setting tmux's pane title via escape sequence, and you'd use #{pane_title} instead of #{pane_current_path}. For bash, add something like this to ~/.bashrc:

[[ -n "$TMUX" ]] && PROMPT_COMMAND='echo -n -e "\e]2;${PWD##*/}\e\\"'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .