Last active
August 29, 2015 13:57
-
-
Save motyar/9885182 to your computer and use it in GitHub Desktop.
Auto start and stop ssh tunnel, for super fast remote editing with Vim
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
"{{{ Start and stop ssh tunnel, Fast remote editing idea via http://www.erikzaadi.com/2013/03/07/fast-remote-editing-with-vim/ | |
function! StartSshTunnel(machine) | |
let shellcmd = "ssh ".a:machine." -f -N -o ControlMaster=auto -o ControlPath=/tmp/%r@%h:%p" | |
let tunnel=system(shellcmd) | |
endfunction | |
function! StopSshTunnel() | |
let kill = system("lsof -i -n | grep ssh | awk '{print $2}' | xargs kill -9") | |
endfunction | |
au FileType netrw au VimEnter * call StartSshTunnel(g:netrw_machine) | |
au FileType netrw au VimLeave * call StopSshTunnel() | |
"}}} | |
" More vim Hacks in my .vimrc https://github.com/motyar/dotfiles/blob/master/.vimrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment