Skip to content

Instantly share code, notes, and snippets.

@max-b
Created April 6, 2018 23:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-b/0506f853e04a2431a66a730614474894 to your computer and use it in GitHub Desktop.
Save max-b/0506f853e04a2431a66a730614474894 to your computer and use it in GitHub Desktop.
Example of tmux config with more than 2 conditional bindings to single key. Useful for vim-tmux-navigation
# Smart pane switching with awareness of vim and fzf and ctrlp
forward_programs="view|n?vim?|ctrlp"
should_forward="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?($forward_programs)(diff)?$'"
bind -n C-h if-shell "$should_forward" "send-keys C-h" "run-shell '[ #{pane_at_left} -eq 1 ] && tmux previous-window || tmux select-pane -L'"
bind -n C-l if-shell "$should_forward" "send-keys C-l" "run-shell '[ #{pane_at_right} -eq 1 ] && tmux next-window || tmux select-pane -R'"
bind -n C-j if-shell "$should_forward" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$should_forward" "send-keys C-k" "select-pane -U"
bind -n C-\ if-shell "$should_forward" "send-keys C-\\" "select-pane -l"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment