Skip to content

Instantly share code, notes, and snippets.

@caifara
Created January 23, 2011 21:50
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 caifara/792477 to your computer and use it in GitHub Desktop.
Save caifara/792477 to your computer and use it in GitHub Desktop.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function Send_to_Screen(text)
if !exists("g:slime")
call Screen_Vars()
end
let escaped_text = substitute(shellescape(a:text), "\\\\\n", "\n", "g")
call system("screen -S " . g:slime["sessionname"] . " -p " . g:slime["windowname"] . " -X stuff " . escaped_text)
endfunction
function Screen_Session_Names(A,L,P)
return system("screen -ls | awk '/Attached/ {print $1}'")
endfunction
function Screen_Vars()
if !exists("g:slime")
let g:slime = {"sessionname": "", "windowname": "0"}
end
let g:slime["sessionname"] = input("session name: ", g:slime["sessionname"], "custom,Screen_Session_Names")
let g:slime["windowname"] = input("window name: ", g:slime["windowname"])
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vmap <C-c><C-c> "ry :call Send_to_Screen(@r)<CR>
nmap <C-c><C-c> vip<C-c><C-c>
nmap <C-c>v :call Screen_Vars()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment