Sunday, November 19, 2006

GNU screen

What is GNU screen?
A free terminal developed by the GNU Project. It allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from the command line, and for separating programs from the shell that started the program.

This is said to be a text version of the graphical window manager. This program together with irssi allows me to stay idling on irc all the time, GNU screen is basically where the magic happens.

Using GNU screen however takes a bit of learning first. So if you are on a UNIX terminal type
screen


This will bring you into a new screen session and if you type
screen -list


It will show you the number of screen sessions you currently have

[limed@shell][~]# screen -list
There is a screen on:
17206.pts-0.shell (Attached)
1 Socket in /var/run/screen/S-limed.


Now every screen command has the format Ctrl-A, and since we are in a screen session now we will can detach from a screen session by hitting Ctrl-A,d When this is done you will see your terminal will print out the word [Detached], and this indicates that you are no longer in a screen session, but whatever application you are running in the screen session is still running.

So now let say we want to reattach back to the screen session on the terminal we type the following command

[limed@shell][~]# screen -rd

The -r switch indicates that you want to resume the screen session, -d switch means that if you have a screen session somewhere it detaches it and resumes on your current machine you are working on. Now you should be able to use screen

That is a simple introduction to GNU screen, and here are more commands for GNU screen

C-a 0 (select 0)
... ...
C-a 9 (select 9) Cycles through the screen sessions you have
C-a C-a (other) Toggle to the window displayed previously.
C-a a (meta) Send the command character (C-a) to window. See escape
command.
C-a A (title) Allow the user to enter a name for the current window.
C-a c
C-a C-c (screen) Create a new window with a shell and switch to that window.
C-a C (clear) Clear the screen.
C-a d
C-a C-d (detach) Detach screen from this terminal.
C-a D D (pow_detach) Detach and logout.
C-a k
C-a C-k (kill) Destroy current window.
C-a space
C-a n
C-a C-n (next) Switch to the next window.
C-a w
C-a C-w (windows) Show a list of window.
C-a ? (help) Show key bindings.

Note that C-a means Ctrl-a

Credits:
Wikipedia - GNU Screen entry
irssi - Documentation page

No comments: