Get current directory of last tmux pane
I’m looking for a tmux
command to obtain the current directory (#{pane_current_path}
) of the last focused pane, that doesn’t require switching to it and switching back.
The following works:
tmux last-pane
echo "$(tmux display-message -pF "#{pane_current_path}")"
tmux last-pane
however I was wondering if there is a way to do this without having to call tmux last-pane
twice (perhaps a variable that contains the ID of the last pane?).
You can use tmux
‘s display-message
sub command with -t
(target-pane)1 flag. For example you can run
tmux display-message -p -t ! "#{pane_current_path}"
will show details of last pane.
1. https://manpages.debian.org/bookworm/tmux/tmux.1.en.html#Token~2