From 9385536e70f4b493f1d58216f1a05aea8cef3705 Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Sat, 2 Jan 2016 00:55:36 +0100 Subject: [PATCH] Use new syntax for smart pane navigation As recommended in original source. As opposed to failing with a message that the command returned 1 and losing access to everything on this screen, this will warn on the status bar if only one pane is present. --- tmux/tmux.conf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index ac9fb3a..2901d44 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -22,11 +22,12 @@ bind -r L resize-pane -R 5 # Smart pane switching with awareness of vim splits. # Source: https://github.com/christoomey/vim-tmux-navigator -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R" -bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l" +is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"' +bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" # Use vi keybindings for tmux commandline input. # Note that to get command mode you need to hit ESC twice...