Terminal: Difference between revisions
No edit summary  | 
				No edit summary  | 
				||
| Line 17: | Line 17: | ||
** add this to "your screen .rc file" to send buffer to X clipboard too!  | ** add this to "your screen .rc file" to send buffer to X clipboard too!  | ||
  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"'  | ||
=== 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  | |||
=== Drop a dead ssh session ===  | |||
Remember this one to drop a dead ssh session!  | |||
 [enter]~.  | |||
Revision as of 18:41, 1 September 2017
The linux terminal is your lifeblood. There are so many - TOO MANY - options. I'll gather a few of my favorite things here.
Host-specific color and banner
This is mucho importante to quickly tell which machine you are on:
- use figlet and jp2a to create ascii art
 - update ~/.bashrc to echo the ascii art in a host-specific color, and to persist that color in the prompt
 - make sure to include an interactive check to avoid the banner if not interactive
 
See the many examples of .bashrc in the config repo.
Keyboard-driven copy-paste
HOW DID I LIVE SO LONG WITHOUT THIS! You can do keyboard-driven copy-paste from terminal buffer using screen!
- 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!
 
 
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
Drop a dead ssh session
Remember this one to drop a dead ssh session!
[enter]~.