Installing / configuring GNU Screen…

Hi all.

Today I will try to show You how to install and configure GNU Screen.

First? What is Screen. Manual page explains it very well.

Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). Each virtual terminal provides the functions of a DEC VT100 terminal and, in addition, several control functions from the ISO 6429 (ECMA 48, ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows.

By default screen looks something like this:

Screen 001

Screen 002

It looks like a ordinary console window. In my own words I would call Screen “many console windows in one…” it’s not a perfect description but that’s the best one that I could come up with. By default screen does not looks very interesting does it?

And what if I will tell You that by copying and pasting few commands You can make it look like this? This is a screenshot taken from my pCLI-NoX installation.

Screen 003

or like this if You are using KDE4…

Screen 004

Still not interested? And what if I will tell You that if You ssh to Your shell account and run screen command and then close the connection the screen will stay active and that You can re-open it when You connect next time with screen -dr command? Better huh? Thought so… And if I will tell You that You can share the screen session with a friend to show Him what are You doing at the moment or to teach him something new? Hehe I see I got Your attention. You are still reading aren’t You?

Ok first things first – we need to install screen then we will configure it. I assume that You have fully upgraded Your PCLinuxOS installation. Run those commands:

su

Give it a root password and then run:

apt-get update && apt-get install screen

Wait till it’s finished and run:

exit

You should be back into the user mode. Now copy and paste the following commands:

cp /etc/screenrc $HOME/.screenrc

mkdir -p $HOME/.bin

touch $HOME/.bin/my_battery.sh

chmod +x $HOME/.bin/my_battery.sh

echo 'acpi -b | cut -f 2 -d |' > $HOME/.bin/my_battery.sh

touch $HOME/.bin/my_temperature.sh

chmod +x $HOME/.bin/my_temperature.sh

echo 'acpi -t | cut -f 2 -d |' > $HOME/.bin/my_temperature.sh

echo 'caption always "%{= Wk}%-w%{= Bw}%n %t%{-}%+w %-="' >> $HOME/.screenrc

echo 'defutf8 on' >> $HOME/.screenrc

echo 'backtick 1 1 0 $HOME/.bin/my_battery.sh' >> $HOME/.screenrc

echo 'backtick 2 1 0 $HOME/.bin/my_temperature.sh' >> $HOME/.screenrc

echo 'hardstatus alwayslastline "%{+b kr}[%H]%{kg} %1`%{kw} %2` %{ky}Load: %l%-=%{kb}%c %d.%m.%Y"' >> $HOME/.screenrc

sed -i 's/#startup_message off/startup_message off/' $HOME/.screenrc

After all this You should see something like this:

Screen 005

Now type in:

screen

and You should see something like this:

Screen 006

Voila! All done. Now close the Konsole window and reopen a fresh one.

Screen 007

Type in:

screen -dr

Screen 008

Screen session is now re-attached to Your Konsole window.

Screen 009

That’s one of the coolest things about screen.

Now I said there are multiple windows in one right? Right. See this whiteish bar with blue rectangle on it and with the 0 bash in it? Make sure that the Konsole window has focus and press and hold CTRL + A and then let them both go and press C.

Screen 010

Now look at that white bar. There are two entries 0 bash and 1 bash. Blue color rectangle moved to the second entry. Why? By pressing the above combo You have opened another “window” in screen and it has the focus now.

As You have probably noticed CTRL + A + key is how the screen operates. It’s very simple and the basic keys are:

c – open / create new window.
n – go to next window
p – go to previous window
k – kill the active window (must be confirmed by pressing y)

Those are the basic things You need to know about screen. Want more? Ok. Have fun. The Key bindings section should be of interest to You.

Special thanks to Hootiegibbon who wrote a large part of the .screenrc file config. Also thanks to Enlik for showing me (and helping with config of) the GNU Screen app in the first place and for helping me when I got stuck at some point while writing this howto.

Hope someone will find it useful.

Regards.

Andy

AndrzejL

"Never meet Your heroes. Most of the time you'll only end up disappointed." White Polak Male Husband Employee Hetero Carnivorous Fugly Geek @$$hole with ADD Catholic “Some men just want to watch the world burn.”

Comments are closed.