I have used tmux on linux systems and Mac OSX with no problem. I am aware that as of version 1.9 (I have 1.9a according to tmux -V
), you are required to do something along the lines of tmux split-window -c "#{pane_current_path}"
. That doesn't work, though. Nothing seems to work.
The best "hint" I can give is that the -c
parameter appears to be recognized in some form, as I get an error about an invalid path if I give it an explicit path that I know does not exist. However, giving it an explicit path does nothing (I thought maybe there was a problem with using pane_current_path
.
There is a chance there are two questions here, as tmux does not start in the current folder, which is default behavior, I believe.
Anybody know what's going on? Is this expected behavior? Am I missing a library somewhere?
With the following in your .tmux.conf
::
set-environment -g CHERE_INVOKING 1
Then tmux split-window -c "#{pane_current_path}"
drop me at/
, but tmux split-window -c $PWD
works.
Found at http://article.gmane.org/gmane.comp.terminal-emulators.tmux.user/5921
kraiz's answer using set-environment
and $PWD
did not work for me.
Instead, I set the environment variable in my login script (~/.bash_profile
for bash, ~/.zprofile
for zsh):
export CHERE_INVOKING=1
Also, $PWD
did not work for me, but #{pane_current_path}
did. Here's a snippet of my .tmux.conf
:
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
Software: tmux 2.0, Cygwin 1.7.35, zsh 5.0.6, Windows 10
That solution instead of CHERE_INVOKING used above will preserve your symlink path:
# .bashrc
# set pwd for tmux
function set_tmux_pwd() {
[ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#D" | tr -d %) "$PWD"
return 0
}
function my_cd() {
\cd $1
set_tmux_pwd
}
set_tmux_pwd
alias cd=my_cd
and
# .tmux.conf
# this support symbolic link
bind c run-shell 'tmux new-window "cd \"$(tmux show-environment $(echo "TMUXPWD_#D" | tr -d %) | sed -e "s/^.*=//")\"; exec $SHELL"'
bind '"' run-shell 'tmux split-window -v "cd \"$(tmux show-environment $(echo "TMUXPWD_#D" | tr -d %) | sed -e "s/^.*=//")\"; exec $SHELL"'
bind '%' run-shell 'tmux split-window -h "cd \"$(tmux show-environment $(echo "TMUXPWD_#D" | tr -d %) | sed -e "s/^.*=//")\"; exec $SHELL"'
https://github.com/tmux/tmux/issues/1282#issuecomment-559033047
It works on cygwin 3.1.4 and tmux 2.6
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