Skip to content

Instantly share code, notes, and snippets.

@tsukkee
Created October 17, 2010 13:32
Show Gist options
  • Select an option

  • Save tsukkee/630857 to your computer and use it in GitHub Desktop.

Select an option

Save tsukkee/630857 to your computer and use it in GitHub Desktop.
Vimとtmuxのウィンドウを区別せずに移動したい
function! MoveCursorWithTmux(vim_dir, tmux_dir)
let old_winnr = winnr()
execute "normal! \<C-w>" . a:vim_dir
" フォーカスがうつってなかったら
if old_winnr == winnr()
silent call system('tmux select-pane -' . a:tmux_dir)
endif
endfunction
for [vim_dir, tmux_dir] in [['h', 'L'], ['j', 'T'], ['k', 'D'], ['l', 'R']]
execute printf("nnoremap <silent> <C-w>%s :<C-u>silent call MoveCursorWithTmux('%s', '%s')<CR>",
\ vim_dir, vim_dir, tmux_dir)
endfor
set statusline=[[pattern]]
bind-key j select-pane -D\; run-shell ~/vim_tmux_helper.sh
bind-key C-j select-pane -D\; run-shell ~/vim_tmux_helper.sh
bind-key k select-pane -U\; run-shell ~/vim_tmux_helper.sh
bind-key C-k select-pane -U\; run-shell ~/vim_tmux_helper.sh
bind-key h select-pane -L\; run-shell ~/vim_tmux_helper.sh
bind-key C-h select-pane -L\; run-shell ~/vim_tmux_helper.sh
bind-key l select-pane -R\; run-shell ~/vim_tmux_helper.sh
bind-key C-l select-pane -R\; run-shell ~/vim_tmux_helper.sh
#!/bin/sh
tmux capture-pane
if tmux show-buffer | grep [[pattern]] > /dev/null
then
tmux set-option prefix C-f > /dev/null 2> /dev/null
# tmux display-message "prefix C-f"
else
tmux set-option prefix C-f,C-w > /dev/null 2> /dev/null
# tmux display-message "prefix C-f,C-w"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment