Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inconsistent tmux new-window behavior

Tags:

tmux

I just installed tmux on my new MacBook Pro, and am running into the following issue.

When I create a new window via the command tmux new-window I get a new window with the same working directory as the session I'm creating from. This is the behavior I expect/desire.

When I create a new window using C-b C-c, I get a new window in my home directory.

Why are my shortcut keys giving me different behavior/how do I make them use the same directory?

like image 646
gusto Avatar asked Feb 27 '14 20:02

gusto


2 Answers

Since Tmux 1.9 you should use the -c option in order to open a new working directory of the current pane.

tmux new-window -c '#{pane_current_path}'

Add this to your tmux.conf:

bind c new-window -c '#{pane_current_path}'

Note: It is also possible that you will have to exit all running instances of the TMUX server before any changes to the .tmux.conf file will be loaded.

like image 78
Rodri_gore Avatar answered Oct 16 '22 13:10

Rodri_gore


If you also want split windows in the current directory, you can add this to tmux.conf:

bind "\"" split-window -c '#{pane_current_path}'
bind "\%" split-window -h -c '#{pane_current_path}'
like image 9
mmm Avatar answered Oct 16 '22 13:10

mmm