Screen Cheet Sheet

From Federal Burro of Information
Revision as of 15:40, 20 April 2018 by David (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

first thing's first:

man screen

Do you have cool screen tricks?

move control-a to control-w with an alias, in bash, like this:

Alias

alias screen='screen -e ^Wa'

why would i want to do that? control-a means beginning of line by default. If you make screen's mate control-a you not longer have a "beginning of line" control sequence.

  • good external page with some info here [1]

How to do other cool stuff?

  • windows names and titles
screen -S "myscreename"

show up when you

screen -l
  • change the session name:
C-a : sessionname mysession

Screenrc

  • cool hardstatus lines, in your .screenrc file:

MC style:

hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a"

Wide:

hardstatus on
hardstatus alwayslastline
hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]"

my current config:

hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a"
defscrollback 10000
scrollback 10000


  • scroll back, in your .screenrc file:
termcapinfo xterm 'bc@:bs@'

useful key sequences

  • meta-escape - pageup, pagedn to scroll back in the screen buffer ( you can use arrow keys and page up page down to scroll around)
  • meta-space - next window
  • meta-backspace - backwards through windows.
  • meta-meta - previous window
  • meta-A - allows you to rename a screen (if you can find a way to rename screens dynamically based on hostname, post it here for a chance to win a mars bar!)
  • meta-" - allows you to select a screen by name.
  • meta-' - allows you to select a screen by number.


Screen and ssh-agent2

This process will only work with ssh-agent forwarding.

Make sure you have a screenrc file in your home directory. If not copy the default.

cp /etc/screenrc ~/.screenrc

Now add the following line to ~/.screenrc and make sure ~/tmp exist.

setenv SSH2_AUTH_SOCK $HOME/tmp/socket

Next step is to add the following to .bashrc --> IM NOT SURE THIS WORKS

if [ -S $HOME/tmp/socket ]; then
        echo "ssh-agent2 socket already exist"
else
        /bin/rm $HOME/tmp/socket
        ln -s $SSH2_AUTH_SOCK $HOME/tmp/socket
fi


in bashrc: I KNOW THIS WORKS

if [[ $TERM != "screen" ]] ; then
    touch ~/.agent.tmp
    chmod 600 ~/.agent.tmp
    set | grep SSH > ~/.agent.tmp
fi

if [ -a ~/.agent.tmp ] ; then
    if [[ $TERM == "screen" ]] ; then
    . ~/.agent.tmp
    fi
fi