Navigation: home » linux » screen

GNU screen configuration file

Over the last few years using screen I have stolen bits and pieces from other screen configuration files. Recently, I found the one below, which is very useful and works well.

This is designed to be your ~/.screenrc file. The bindkey lines will set Alt-< and Alt→ to move between windows left and right.

# Look and feel
caption always "%{= bb}%{+b w}Screen: %n | %h %=%t %c"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"

# Our warning of activity
activity "Activity in %t(%n)"

# Left Right meta key mods
#ALT-,. and ALT-<>
bindkey "^[<" eval number !echo $WINDOW-1|bc
bindkey "^[>" eval number !echo $WINDOW+1|bc
bindkey "^[," prev
bindkey "^[." next

To activate the caption output, the following should added to your ~/.bashrc also:

# Change the window title of X terminals
case $TERM in
        screen)
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
                ;;
esac

With the above activated in your ~/.bashrc (don’t forget to restart screen!), you should notice directory and process information appear just above the window tabs.

Example

The example below shows five windows, each with its own tab. There is space for the caption output from whatever is currently running in your shells, the example above prints your current username, host and working directory.