How to change the starting directory of a tmux session?

后端 未结 3 1001
失恋的感觉
失恋的感觉 2021-02-05 01:03

The directory where you start a tmux session in will be the directory that all new windows will start at.

My question is, how can you change this starting directory wit

3条回答
  •  无人及你
    2021-02-05 01:51

    The way to do this is to detach from the session (^b d with the default keybindings) and then specify a different directory when you reattach to it. When attaching to a session, use the -c flag to specify the working directory. Here's an example:

    $ tmux list-sessions
    tmuxwtfbbq: 3 windows (created Tue Apr  5 14:25:48 2016) [190x49]
    $ tmux attach-session -t tmuxwtfbbq -c /home/chuck/new_default_directory
    

    This setting will be persisted - after you've reset the working directory, you won't need to keep specifying it every time you reattach to the session.

    For the record, I'm on tmux version 2.0 (though I don't think it matters - I couldn't find anything about adding a -c option to the attach-session command in the change logs so I assume it's been there for quite a while).

提交回复
热议问题