Last active
April 19, 2017 02:26
-
-
Save junegunn/2f271e4cab544e86a37e239f4be98e74 to your computer and use it in GitHub Desktop.
This file contains 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
" ---------------------------------------------------------------------------- | |
" tmux | |
" ---------------------------------------------------------------------------- | |
" Recommended | |
let mapleader = ' ' | |
function! s:tmux_send(content, dest) range | |
let dest = empty(a:dest) ? input('To which pane? ') : a:dest | |
let tempfile = tempname() | |
call writefile(split(a:content, "\n", 1), tempfile, 'b') | |
call system(printf('tmux load-buffer -b vim-tmux %s \; paste-buffer -d -b vim-tmux -t %s', | |
\ shellescape(tempfile), shellescape(dest))) | |
call delete(tempfile) | |
endfunction | |
function! s:tmux_map(key, dest) | |
execute printf('nnoremap <silent> %s "tyy:call <SID>tmux_send(@t, "%s")<cr>', a:key, a:dest) | |
execute printf('xnoremap <silent> %s "ty:call <SID>tmux_send(@t, "%s")<cr>gv', a:key, a:dest) | |
endfunction | |
call s:tmux_map('<leader>tt', '') | |
call s:tmux_map('<leader>th', '.left') | |
call s:tmux_map('<leader>tj', '.bottom') | |
call s:tmux_map('<leader>tk', '.top') | |
call s:tmux_map('<leader>tl', '.right') | |
call s:tmux_map('<leader>ty', '.top-left') | |
call s:tmux_map('<leader>to', '.top-right') | |
call s:tmux_map('<leader>tn', '.bottom-left') | |
call s:tmux_map('<leader>t.', '.bottom-right') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment