Quantcast
Channel: The Basement Coders Developer Podcast » craig
Viewing all articles
Browse latest Browse all 104

Functioning in Screen

$
0
0
I've used screen for years, probably since the 50th time I got booted off an irc server because my connection was broken. It also came in handy when I was compiling something that took a long time to finish.

Screen allows you to keep a terminal session alive even if your ssh or telnet session drops. If you were disconnected you would simply log back in and type:

screen -rd

Attaching to an existing Screen

That command tells screen to reattach (-r) to an existing screen session and detach any existing person attached to screen (-d).

Using the Scrollback Buffer

Once you are in screen you may run into a few situations where, in your normal terminal session, you would be able to press page up/page down to navigate through your scrollback history. Under screen, this is achieved by entering command mode (Ctrl-a) and then the following (from the screen man page):

h, j, k, l move the cursor line by line or column by column.
0, ^ and $ move to the leftmost column, to the first or last non-whitespace character on the line.
H, M and L move the cursor to the leftmost column of the top, center or bottom line of the window.
+ and - positions one line up and down.
G moves to the specified absolute line (default: end of buffer).
| moves to the specified absolute column.
w, b, e move the cursor word by word.
B, E move the cursor WORD by WORD (as in vi).
Ctrl-u  and  Ctrl-d  scroll the display up/down by the specified amount of lines while preserving the cursor position. (Default: half screen-full).
Ctrl-b and Ctrl-f scroll the display up/down a full screen.
g moves to the beginning of the buffer.
% jumps to the specified percentage of the buffer.

Remember, for the above commands to work you have to enter screen's command mode by pressing Ctrl-a first.

Using Ctrl-a, but not for Command mode

Another problem you might encounter is, within your irc program or on the command line you might be used to pressing Ctrl-a to move the cursor to the first character of your line. Problem is, screen uses Ctrl-a as it's command mode key. Not a problem though, simply type "Ctrl-a" followed by "a"

Multiple Screens

The good thing about screen is, you don't need multiple screen instances, you use the same screen instance and simply create new sub-screens. To do this, enter command mode (Ctrl-a) and type the letter "c" for "create". That will create a new terminal for you and place you at the command prompt. To get back to the previous screen, just type "Ctrl-a" followed by "Ctrl-a". That lets you flip back and forth between two screens. If you have more than two screens, you can flip directly to a screen using it's number. The first screen has a number of "0", the second "1", etc... To flip to the 3rd screen you would type "Ctrl-a" followed by "2".

Detaching from Screen

Once you are finished with your session and you wish to disconnect (but keep your session running) simply enter command mode (Ctrl-a) and type "d" to detach your screen.


Viewing all articles
Browse latest Browse all 104

Trending Articles