Skip to content

Instantly share code, notes, and snippets.

@rahulkmr
Created September 21, 2010 16:03
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 rahulkmr/589934 to your computer and use it in GitHub Desktop.
Save rahulkmr/589934 to your computer and use it in GitHub Desktop.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function Send_to_Screen(text)
if !exists("g:screen_sessionname") || !exists("g:screen_windowname")
call Screen_Vars()
end
let s:foo_text = substitute(a:text, '\n\s*\n\+', '\n', 'g') . "\n"
echo system("screen -S " . g:screen_sessionname . " -p " . g:screen_windowname . " -X stuff '" . substitute(s:foo_text, "'", "'\\\\''", 'g') . "'")
endfunction
function Screen_Session_Names(A,L,P)
return system("screen -ls | awk '/Attached/ {print $1}'")
endfunction
function Screen_Vars()
if !exists("g:screen_sessionname") || !exists("g:screen_windowname")
let g:screen_sessionname = ""
let g:screen_windowname = "0"
end
let g:screen_sessionname = input("session name: ", "", "custom,Screen_Session_Names")
let g:screen_windowname = input("window name: ", g:screen_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