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
Here's how you can change the tmux session's working directory without detaching the session, and without needing use to the
keystrokes:
tmux
command prompt:tmux command-prompt "attach -c %1"
...will open a command prompt, then you type the working directory you want ~/my/dir
and press ENTER
# Execute this in one of the shell panes of within your tmux session:
tmux command-prompt -I $PWD -P "New session dir:" "attach -c %1"
With this approach, the prompt for new-directory is pre-populated with the current dir of the pane which launched the command. Of course you can substitute anything else for $PWD
if you please.
I have added this to my shell initialization:
# Change the current directory for a tmux session, which determines
# the starting dir for new windows/panes:
function tmux-cwd {
tmux command-prompt -I $PWD -P "New session dir:" "attach -c %1"
}
With all of these options, any future new windows will start in the given dir.
Note: attach
, attach-session
, and a
are all aliases for each other. The tmux command-prompt
has many other powers, it's worth reading the man page