Use tmux window option for pane change detection

Improve tmux integration when changing buffers or panes when vim was
invoked by another process so that seamless navigation works when the
`vim$TMUX_PANE` window option has been set, not only when the pane's
command matches a simple regex.
This commit is contained in:
Kenneth Benzie 2019-08-11 18:56:10 +01:00
parent 10eb5fffea
commit 1f07473b57

View File

@ -1,6 +1,13 @@
augroup benieAugroup
autocmd!
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
" Reopening a file at last curson position
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\ | exe "normal! g'\"" | endif