I'm using tmux 2.0, Ubuntu 14.04.2 LTS in VirtualBox.

In order to make tmux open new windows with the same path as the current window I added this line to my ~/.tmux.conf file:

bind c new-window -c "#{pane_current_path}"

Note that in tmux, if I cd from home to a subdirectory via a symlink, then check pwd and pwd -P I get:

~$ cd pythons
~/pythons$               # An awesome prompt

~/pythons$ pwd           # According to "man pwd" this shows the "logical" path

~/pythons$ pwd -P        # and this shows the "physical" path

The problem is

If I open a new tmux window while in ~/pythons the new bash prompt takes on the physical path:

/media/sf_Google_Drive/Home/Programs/Pythons$     # Not an awesome prompt

Q: Yes, it's opened to the correct directory... but is there a way to get tmux to start bash with the logical path instead of the full-blown physical path?

Alternatively, perhaps there is something I can add to .bashrc to make this happen?


To check if any config settings are causing this issue I tried commenting out all lines in ~/.tmux.conf except for

bind c new-window -c "#{pane_current_path}"

but I still get the full physical path. I also tried echoing the current (logical) path from the top of my ~/.bashrc file. Unfortunately, this echos the ugly physical path of the parent window, which apparently has become the new window's physical and logical path. So tmux 2.0 must be passing it to the new bash instance via the value of "#{pane_current_path}"

Moreover, I just found this recently opened tmux issue: pane_current_path doesn't agree with pane's PWD #33 indicating that this behavior originates in tmux code.

Q: So maybe my question should be, Is there a workaround?

  • You should check .bashrc or other sourced files. Jun 28, 2015 at 8:25
  • 1
    @HongxuChen That won't help: it's tmux doing that before it starts bash, bash doesn't know which path was previously used inside tmux. Jun 28, 2015 at 22:50
  • I'm using zsh and tmux and it prompts logical path for symlink files. Can you paste ~/.tmux.conf ? Jun 29, 2015 at 2:59
  • My ~/.tmux.conf doesn't contain anything fancy but I did check if it was a problem. Please see edit above. Jun 29, 2015 at 5:39

1 Answer 1


The following worked for me.

To ~/.bashrc, add the line:

PS1='$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I") $PWD)\u@\H:\w$ '

And to ~/.tmux.conf, add the lines:

bind-key c run-shell 'tmux neww "cd $(tmux display -p "\$TMUXPWD_#I"); exec bash"'
bind-key % run-shell 'tmux splitw -h "cd $(tmux display -p "\$TMUXPWD_#I"); exec bash"'
bind-key '"' run-shell 'tmux splitw -v "cd $(tmux display -p "\$TMUXPWD_#I"); exec bash"'

Restart tmux.


See the section, "How can I open a new window in the same directory as the current window?" at http://tmux.svn.sourceforge.net/viewvc/tmux/trunk/FAQ.

Note that the characters at the end of the .bashrc line had to be changed from the original at the link above to '\u@\H:\w$ ' in order to properly display the complete bash prompt. See http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html for more info.

  • A better solution may exist? Note the following example. Assume X and Y are simlinks in ~. cd to ~/X and split window. Now from pane2, cd to ~/Y. Return to pane1 and split window again. Pane3's path becomes ~/Y but should be ~/X. Jul 9, 2015 at 3:38

You must log in to answer this question.

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