Skip to content

Instantly share code, notes, and snippets.

@takeshy
Created March 31, 2011 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeshy/895706 to your computer and use it in GitHub Desktop.
Save takeshy/895706 to your computer and use it in GitHub Desktop.
vim scp
" You should execute pagent before you call those command.
function PutScp()
let s:nowDir = substitute(expand("%:p:h"),"[cC]:\\(.*\\)$","\\1","")
let s:nowFile = expand("%:t")
let s:fn = "c:\\tmp\\scpcmd.txt"
if filereadable(s:fn)
let s:ret = delete(s:fn)
endif
execute "sp ".s:fn
call LineAdd("option batch on")
call LineAdd("open USER_NAME@SERVER_ADDRESS")
call LineAdd("cd ".s:nowDir)
call LineAdd("rm \"".s:nowFile."\"")
call LineAdd("put \"".s:nowFile."\"")
call LineAdd("exit")
execute "w"
execute "q"
execute "!start \"C:\\Program\ Files\ (x86)\\WinSCP\\winscp.exe\" /console /script=\"c:\\tmp\\scpcmd.txt\""
endfunction
function GetScp()
let s:nowDir = substitute(expand("%:p:h"),"[cC]:/\\(.*\\)$","\\1","")
let s:nowFile = expand("%:t")
let s:fn = "c:\\tmp\\scpcmd.txt"
if filereadable(s:fn)
let s:ret = delete(s:fn)
endif
execute "sp ".s:fn
call LineAdd("option batch on")
call LineAdd("open USER_NAME@SERVER_NAME")
call LineAdd("cd " . s:nowDir)
call LineAdd("get \"".s:nowFile."\"")
call LineAdd("exit")
execute "w"
execute "q"
call rename(s:nowFile,s:nowFile . ".bk")
execute "!start \"C:\\Program\ Files\ (x86)\\WinSCP\\winscp.exe\" /console /script=\"c:\\tmp\\scpcmd.txt\""
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment