I assume you ssh
from a local pane and then run tmux
on the remote side.
A simple solution is to add ssh
to the regex. The downside is send-keys C-h
will work regardless if there is tmux
on the remote side. Checking if there is tmux
on the remote side is not trivial (if possible at all in a robust way).
Additionally you may want tmux
as well; this will cover tmux sessions nested locally.
Your code modified:
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)(g?(view|n?vim?)(diff)?|ssh|tmux)$"'
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
Note select-pane -L
in the inner session is unaware of panes of the outer session. It will only select panes of the inner session. IMO building logic that allows you to move around the panes of the inner session and transparently "jump out" to the outer session when you reach the border would be very hard (again: if possible at all in a robust way).