0

I have a tmux config like this on my local and remote machine.

is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'

bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"

I'm trying to move to the other pane in my remote session, but it does not get sent to the nested session. How may I send caps lock + h to switch between all of the panes cleanly?

1 Answer 1

0

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .