4

Is there anyway to find out information about the current working directory of any pane from within a tmux session?

I'd like to write a bash script that changes the directory of the current pane to the directory of another pane, even if that pane has a program or script already running in it.

The way I'd like to do it is to navigate to pane 1, then I'd goto pane 2, hit a hot key and pane 2 would now change to the same pwd as pane 1.

  • 1
    Does this work: tmux display-message -p -F "#{pane_current_path}" -t0? – Arkadiusz Drabczyk May 7 '15 at 12:02
  • yeah that does seem to work... totally add that as an answer! – Brad Parks May 7 '15 at 12:14
9
tmux display-message -p -F "#{pane_current_path}" -t0
  • sweet! this totally worked... and for what it's worth, here's the simple script I put together to allow me to switch the current panes directory to the directory of the last accessed pane. tmux last-pane; DIR=$(tmux display-message -p -F "#{pane_current_path}"); tmux last-pane; cd $DIR, and this can be bound in your ~/.tmux.conf using bind f run "tmux_last_dir" where tmux_last_dir contains the script mentioned before. This would allow you to hit TMUX_PREFIX + f to switch your current pane's folder using the script. – Brad Parks May 7 '15 at 12:46
  • 1
    I'm glad that you like it :) This is what SE is for! – Arkadiusz Drabczyk May 7 '15 at 12:48
  • yeah I spent about an hour playing around with it, and didn't know about the display-message command, which I somehow missed in the man page. That's going to be super useful in itself.... Thanks again! – Brad Parks May 7 '15 at 12:58
  • You are actually saving my life! – arainone Feb 5 '16 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.