Screen Cheet Sheet

From Federal Burro of Information
Jump to: navigation, 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 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


  • 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"


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"
        /bin/rm $HOME/tmp/socket
        ln -s $SSH2_AUTH_SOCK $HOME/tmp/socket

in bashrc: I KNOW THIS WORKS

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

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