August 29, 2008

Firefox like tabs in your console

GNU screen is an extremely useful utility when used on remote machines. If you have a flaky net connection that disconnects often, it can be a boon.

What do mean: "tabs"?

GNU screen emulates a terminal, using your default shell. You start it by simply running

$screen

You get a welcome message and to a working shell. This is your open "tab" or screen. To start a new tab, enter the keys Ctrl-a + c (control-a followed by c). This opens a new tab with an empty shell. the first shell is "0", second is "1" and so on.

To move to shell X, use Ctrl-a + X.. so to go back to the first shell, i hit Ctrl-a + 0.

To scroll up in the tab, when text has run through the screen, press Ctrl+[ , and you are now in scroll mode: you can use the arrow keys, home, end, pgup and pgdown, etc to scroll on the screen. Esc closes the scroll mode.

Screens are persistent

So your network was reset and you connection to the remote server lost. Worry not, screen is still running up there. Login to your account again, and run

screen -x

This will attach to your old screen session, and your wordspace and opened tabs are all present :)

You may always want to start off with screen -x initially. If no session exist, this will report an error and you can start a new session using screen. If one does you will attach to it. If more than one does they will all be listed and you can attach to any one of those.

Multiplayer mode

This feature of attaching to open screen sessions isn't restricted to you alone. Another user logged into the system can also enter screen -x, and join you. You can both now collaborate on the screen! This is extrememly useful when you need the help of another person to get something done.. and you get to see live as they do their thing.

So, hope I've sold you on screen. Use it. The official page is on GNU.org, but its probably alreayd a part of your system or available in your distributions package repository.

Screenshots should be listed at google's result.

Default key bindings for various tasks are here and the manpage is here.

[update: To get a bar at the bottom of the console to list all windows + other details, take a look at the guide at redhatmagazine.com]