Following up on Dustin's blog about our idea of proposing screen configurations for ubuntu server, here is how I have set up my environment to use screen by default on my machines.
First of all, I modified my .bashrc to add the following at the end:
if [ "$TERM" != "screen" ]; then
#screen -D -R
#Update 2008 Dec 16: -xRR is way better
Which, if my bash session is not opened from a screen, will try to find an existing screen session and reattach to it, otherwise create one. This also prevents opening screen within a screen when connecting to another host with a similar setup.
Update 2008 Dec 16: The -xRR option will not detach a current running screen. It will just reattach to it in multiuser mode and is much more convenient this way. It is marked as the intended method when screen is used as a login shell in the man page, and it is almost what I am doing here...
I also wanted a few additional features:
Since Dustin's package symlinks .screenrc to a common file, I removed the symlink and replaced it with the following, which starts by reading Dustin's default config:
source /usr/share/screen-profiles/profiles/ubuntu.screenrcI am ataching this file here for easier usage.
# Allow scrolling in xterm
termcapinfo xterm ti@:te@
# if activity is detected on an affected window switched into the background
# you will receive the activity notification message in the status line
# the window will also be marked with an ‘@’ in the window-status display
# When any activity occurs in a background window that is being monitored
# screen displays a notification in the message line
activity "activity -> %n%f %t" # window number , flags of the window , window title
# Map shift-tab to go to next window
bindkey "\033[Z" next
# Ctrl+PgUp and Ctrl+PgDn to change windows
bindkey ^[[5;5~ prev
bindkey ^[[6;5~ next**
# Start screen
screen -t motd watch -n 30 cat /etc/motd
screen -t local 0
#Escape as control-W