I recently moved from GNU screen to tmux.
I find it quite similar but with bigger support (I switched due to problem with escape-time in neovim- resolution was only for tmux).

Unfortunately in tmux I'm unable to find a similar command to this:

screen -X eval "chdir $(some_dir)"

The command above changed the default directory for new window/screen/pane from within the GNU screen so when I pressed Ctrl+a (similar to tmux Ctrl+b)- new window opened in the $(some_dir) directory.

Is there a similar thing in tmux?

I have used @Lqueryvg answer and combined it with @Vincent Nivoliers suggestion froma a comment and that gave me a new binding for a command attach -c "#{pane_current_path}" which sets my current directory as a default one.

  • You could use the second answer of this question – Vincent Nivoliers Mar 8 '16 at 13:25
  • Thanks, it is helpful. new-window -c "#{pane_current_path}" is working but what I need is to set the path permanently, i.e.: I'm working in a project in /aaa/bbb but somehow I when I change path to say /ccc/ddd and start new with C-b and c I want to land one more time in /aaa/bbb. Can you think of a solution to this? – lewiatan Mar 8 '16 at 13:41
  • I am personally fine with the addition of the last three lines in my .tmux.conf. That way I only have to navigate once to the folder and then create my windows / split from there, but I admit this is not a solution to your problem, that's why I didn't post an answer ! – Vincent Nivoliers Mar 8 '16 at 13:52
  1. Start tmux as follows:

    (cd /aaa/bbb; tmux)

    Now, any new windows (or panes) you create will start in directory /aaa/bbb, regardless of the current directory of the current pane.

  2. If you want to change the default directory once tmux is up and running, use attach-session with -c.

    Quoting from the tmux man page for attach-session:

    -c will set the session working directory (used for new windows)
    to working-directory.

    For example:

    • Ctrl+b :

    • attach -c /ddd/eee

    New windows (or panes) will now start in directory /ddd/eee, regardless of the directory of the current pane.

  • 7
    Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks. – lewiatan Apr 6 '16 at 7:54
  • Yes! attach -c is exactly what I was looking for. Thank you – Byron Mansfield Aug 10 '18 at 1:37

For those who might be looking for a bit more reference than the selected answer provides, there was an another good answer to this question over on StackOverflow:


Which provides ways you can do it without leaving the session, and for those who use tmux in a multi-session fashion (like myself), the above answer gives a bit better context as to how attach/attach-session works.

See both available answers for different ways they can be used. I found both to be helpful/insightful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.