Take the 2-minute tour ×

Say my present working directory is /home/abc/documents/xyz. Now in tmux, when I split my screen, the new pane defaults to the /home/abc directory. I want the pwd to be retained upon splitting.

share|improve this question
Similair question on unix.exchange, describes how to open new window while retaining the current pwd –  bbaja42 Jun 25 '11 at 21:24
add comment

3 Answers

up vote 0 down vote accepted

You can put something like the following in your tmux.conf file:

bind <key of your choice> default-path $(pwd) \; split-window\; set default-path ~/

This binds to the chosen or a command which changes the default path for new panes to the current directory of the current pane (via the output of pwd) and then splits the pane, and then binds it back to home.

I read this trick on ArchWiki a while back. There's another more in-depth method that uses cd if you follow the link, though it has its own issues so I'd personally recommend sticking with what's shown above.

share|improve this answer
The tip you linked to works when it is executed from a shell command line because the shell expands the $() command substitution. However, this same command cannot actually “be easily bound to a key” because tmux does not do command substitution for the value given to set default-path (even if it did, the effective cwd would be that of the server, not that of the foreground process of the active pane). –  Chris Johnsen Dec 9 '11 at 6:17
Also, there really is no need to even mess with default-path for the case of creating a pane/window with the same cwd as an existing shell because tmux split-window/tmux new-window from (e.g.) a shell will pass its cwd (inherited from its parent, (e.g.) the shell) to the process started for the new pane. –  Chris Johnsen Dec 9 '11 at 6:42
A note since I'm not allowed to make that small of an edit: the first default-path above should be set default-path. –  Henrik N Feb 28 '12 at 22:14
add comment

theres a zsh-plugin for that https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/last-working-dir/last-working-dir.plugin.zsh

coincidentally I have this behaviour via a ssh:ed session but I don't know what setting this is.

share|improve this answer
add comment

The default-path described on a previous answer is no longer a compatible, this behavior was changed from tmux 1.8 to tmux 1.9.

The way to do this now is to have binds that do neww -c '#{pane_current_path}' or the same with split-window.

Please refer to the changes exposed here: http://sourceforge.net/p/tmux/tmux-code/ci/master/tree/CHANGES , in the section that reads CHANGES FROM 1.8 to 1.9, 20 February 2014.

share|improve this answer
add comment

Your Answer


