Fix navigation annoyances
Fixes #6 by setting a window option called `vim$TMUX_PANE` during vim setup, and removing it when vim exits: ```vim if $TMUX !=# '' " Set tmux window option to detect when to change pane. let s:tmux_option = '@vim'.substitute($TMUX_PANE, '%', '\\%', 'g') call system('tmux set-window-option '.s:tmux_option.' 1') au VimLeave * call system('tmux set-window-option -u '.s:tmux_option) endif ``` Then update the `is_vim` conditional shell statement to check if this variables exists for the current pane to determine when to change tmux pane or pass through the binding to vim. ```conf in_vim='[[ "$(tmux show-window-options)" = *"@vim#{pane_id}"* ]] && \ [[ "#{pane_current_command}" != zsh ]]' ``` Additionally check if the vim task has been backgrounded by comparing the value of `#{pane_current_command}`, this is likely a bit brittle if backgrounding is used heavily but works otherwise.
This commit is contained in:
parent
b47c74a33f
commit
56739ba2e7
15
tmux.conf
15
tmux.conf
@ -62,14 +62,13 @@ bind '"' split-window -c '#{pane_current_path}'
|
||||
bind '%' split-window -h -c '#{pane_current_path}'
|
||||
|
||||
# Integrate pane selection with vim
|
||||
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||
unbind -T copy-mode-vi C-h
|
||||
unbind -T copy-mode-vi C-j
|
||||
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"
|
||||
in_vim='[[ "$(tmux show-window-options)" = *"@vim#{pane_id}"* ]] && \
|
||||
[[ "#{pane_current_command}" != zsh ]]'
|
||||
bind -n C-h if $in_vim 'send-keys C-h' 'select-pane -L'
|
||||
bind -n C-j if $in_vim 'send-keys C-j' 'select-pane -D'
|
||||
bind -n C-k if $in_vim 'send-keys C-k' 'select-pane -U'
|
||||
bind -n C-l if $in_vim 'send-keys C-l' 'select-pane -R'
|
||||
bind -n C-\ if $in_vim 'send-keys C-\\' 'select-pane -l'
|
||||
|
||||
# Integrate urlview
|
||||
bind u capture-pane \; split-window 'tmux show-buffer | urlview -'
|
||||
|
Loading…
x
Reference in New Issue
Block a user