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 without closing your session?
We can switch session from within tmux: PREFIX + ( : Switch the attached client to the previous session. PREFIX + ) : Switch attached client to the next session. PREFIX + s : Select session from a list of sessions for the attached client interactively.
When we start a new instance of tmux, while a server is running, a new session is created inside the running server. (For Advanced users) You can run multiple tmux servers. See -L flag in the documentation. By default, the tmux server is named “default” and the socket is stored in /tmp.
Switching between panes Alternatively, you can use your arrow keys to navigate to a pane according to your layout. For example, if you've got two open panes divided by a horizontal split, you can press Ctrl+B followed by the Up arrow to switch from the lower pane to the top pane.
Then type "exit" or Ctrl-d. Note that there is no need for Ctrl-b in this step. Once you type "exit" or Ctrl-d in the last remaining pane, tmux will close. You can also exit tmux by pressing : to go to the bottom bar of the tmux window.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With