Tmux: How to configure tmux to display the current working directory of a pane on the status bar?

rajames picture rajames · May 18, 2013 · Viewed 21.3k times · Source

I am new to tmux and I am trying to edit my tmux.conf file to have the left side of the status bar reflect:

[SessionName] [CurrentPane] [CurrentWorkingDirectory]

I am able to display the SessionName and CurrentPane. However I can't get to display the CurrentWorkingDirectory.

I've tried several #(shell command) options:

  1. #(tmux select-pane -t :.#P; pwd) : But this prints some other $PWD variable which does NOT reflect the current directory of the bash session in the current pane.

  2. #(tmux select-pane -t :.#P; tmux send-keys pwd Enter) Firstly, although it did print the CurrentWorkingDirectory if I'm in a terminal. It prints this in the terminal and NOT in the status bar like how I want it. Secondly, It entered "pwd Enter" every 15 seconds whether or not I was in a terminal, which was a hassle to reverse if your not as quick (like I am).

I've tried these options but to no avail, is it possible to do what I want? and how?

Answer

gospes picture gospes · Jan 24, 2014

There is a variable for that, which doesn't seem to be in the manpage but is mentioned in the development version. For me, it works in the 1.8 release of tmux.

set -g status-left "#{pane_current_path}"

Note that it also works when you put it in the window-status. Each window status will mention respective working directories.

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