Created
October 17, 2010 13:32
-
-
Save tsukkee/630857 to your computer and use it in GitHub Desktop.
Vimとtmuxのウィンドウを区別せずに移動したい
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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