Screen: Difference between revisions
 (Created page with " === Copy buffer to clipboard === I should probably prefer an improved set of keys to navigate the screen and copy parts of it...  But for the moment:          https://stackov...")  | 
				No edit summary  | 
				||
| Line 1: | Line 1: | ||
=== Copy buffer to clipboard ===  | === Copy buffer to clipboard ===  | ||
I should probably prefer an improved set of keys to navigate the screen and copy parts of it...  | I should probably prefer an improved set of keys to navigate the screen and copy parts of it...  | ||
| Line 5: | Line 4: | ||
But for the moment:  | But for the moment:  | ||
         1) use screen  |          1) use screen  | ||
         2) set this in your "screen .rc file":  |          2) set this in your "screen .rc file":  | ||
             bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < /tmp/screen-exchange"'  |              bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < /tmp/screen-exchange"'  | ||
=== Keyboard-driven copy-paste ===  | |||
You can do keyboard-driven copy-paste from terminal buffer using screen!  | |||
I'm still perfecting it - PLEASE KEEP GOING!  | |||
* Ctrl-A-esc to get into buffer navigation mode  | |||
* space to mark the start of the copy buffer (non-column)  | |||
* space to mark the end of the copy buffer  | |||
* then you can use Ctrl-A-] to paste - wait, wut?  useless... what about X buffer?  | |||
** add this to "your screen .rc file" to send buffer to X clipboard too! See [https://stackoverflow.com/questions/16111548/how-to-copy-the-gnu-screen-copy-buffer-to-clipboard this SO.]  | |||
 bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < /tmp/screen-exchange"'  | |||
=== Always use screen when ssh'ing ===  | |||
Best to accomplish this with a script.  | |||
This will also allow us to provide host-specific background graphics and profile colors, sweeeeet!  | |||
    mah-haus-provided ssh commands!  | |||
        mh bitpost {screenname}  | |||
            save term background/profile  | |||
            change term background/profile - with host pic in upper right!!  | |||
            use this script to ssh bitpost:  | |||
                https://stackoverflow.com/a/1075956/717274  | |||
                also:  | |||
                    On my Ubuntu system (10.4) I had to modify the regular expression to account for the date/time info it prints next to each session.  | |||
                    if(/^\s*(\d+)\.(\S+)\s+(([^)]*))\s+(([^)]*))/) { ($num, $tag, $status) = ($1, $2, $4); –  | |||
                or:  | |||
                    ssh -t [email protected] /usr/bin/screen -xRR  | |||
                    -t is needed to force terminal creation (even tho sending a command)  | |||
                    -x  | |||
                    -R restore existing or create if none  | |||
                    # see MY screen settings with at to see what i really want  | |||
                better to let screen do the ssh?  | |||
                   screen -S 1-9 -p 0 -X screen -t Remote ssh 19  | |||
            reset term background/profile  | |||
=== Screen Session ===  | |||
I always use screen session names, and show them if set in PS1 (see .bashrc_ui).  | |||
Then using this will create the session if needed or connect if exists.  Perfect.  | |||
 #!/bin/bash  | |||
 # -R will simply reattach if found, otherwise run as if a new request.  | |||
 screen -d -R -S #sessionname# #optionalcommand#  | |||
Revision as of 14:27, 28 February 2018
Copy buffer to clipboard
I should probably prefer an improved set of keys to navigate the screen and copy parts of it...
But for the moment:
       1) use screen
       2) set this in your "screen .rc file":
           bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < /tmp/screen-exchange"'
Keyboard-driven copy-paste
You can do keyboard-driven copy-paste from terminal buffer using screen!
I'm still perfecting it - PLEASE KEEP GOING!
- Ctrl-A-esc to get into buffer navigation mode
 - space to mark the start of the copy buffer (non-column)
 - space to mark the end of the copy buffer
 - then you can use Ctrl-A-] to paste - wait, wut?  useless... what about X buffer?
- add this to "your screen .rc file" to send buffer to X clipboard too! See this SO.
 
 
bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < /tmp/screen-exchange"'
Always use screen when ssh'ing
Best to accomplish this with a script. This will also allow us to provide host-specific background graphics and profile colors, sweeeeet!
   mah-haus-provided ssh commands!
       mh bitpost {screenname}
           save term background/profile
           change term background/profile - with host pic in upper right!!
           use this script to ssh bitpost:
               https://stackoverflow.com/a/1075956/717274
               also:
                   On my Ubuntu system (10.4) I had to modify the regular expression to account for the date/time info it prints next to each session.
                   if(/^\s*(\d+)\.(\S+)\s+(([^)]*))\s+(([^)]*))/) { ($num, $tag, $status) = ($1, $2, $4); –
               or:
                   ssh -t [email protected] /usr/bin/screen -xRR
                   -t is needed to force terminal creation (even tho sending a command)
                   -x
                   -R restore existing or create if none
                   # see MY screen settings with at to see what i really want
               better to let screen do the ssh?
                  screen -S 1-9 -p 0 -X screen -t Remote ssh 19
           reset term background/profile
Screen Session
I always use screen session names, and show them if set in PS1 (see .bashrc_ui).
Then using this will create the session if needed or connect if exists. Perfect.
#!/bin/bash # -R will simply reattach if found, otherwise run as if a new request. screen -d -R -S #sessionname# #optionalcommand#