The is_vim
command below works with the tmux if-shell
command to properly detect if vim is open in the current pane, and if so then sends the key command below.
But, it is not working with run-shell
, and I'm not sure why. With run-shell
, the if statement always seems to evaluate to false and it always called the tmux select-pane command below.
# is_vim is directly from the setup guide for https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
# Comment out one of the below to test
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n C-h run-shell "if [ $is_vim ]; then tmux send-keys C-l; else tmux select-pane -R; fi"