Sunday, August 20, 2006

Start GNU Screen Automatically

GNU Screen is a very useful program that creates multiple interactive shells inside one physical terminal. It is extremely useful for system administrators and for using with SSH connections and tunnels. See the webpage for more information, guides and manuals.

To have screen start automatically upon login, add the following line to ~/.bash_profile.
exec /usr/bin/screen

Add the following to ~/.bashrc. This produces a message acknowledging screen is activated.
if [ "$TERM" = "screen" ]; then
echo "[ screen is activated ]"
fi

Add the following to ~/.screenrc. It prevents screen from popping up its startup message; and defines the number of scrollback lines available.
startup_message off
defscrollback 10000

Finally, to force xterm to start bash as a login shell (so that bash reads ~/.bash_profile), add the following line to ~/.Xresources. (This will have to be modified appropriately for other terminals.)
Xterm*loginShell: true

You can implement the changes to ~/.Xresources with the following command.
xrdb ~/.Xresources