|
First thing I add is vbell off which makes stupid attempts of tab-completion more bearable, these and other errors are then shown in xterm's heading bar instead of making the terminal blinking and flashing. Screen can also be told to open several terminals at startup, and even assign more meaningful names to those terminals in e.g. the list of terminals shown by C-a " . The following examples explain the syntax:
These commands open a second window with the title E-Mail and the mailbox view of Mutt. The reason I put the first window at the end is because I like to open a root shell for whatever administrative tasks and want Screen to dump me to the password request. Otherwise I would end in raggle and had toC-a n to it. Other ways of preselecting windows are explained in the man page for the option -p. The different notation for mp3blaster keeps that terminal alive after quitting mp3blaster: Exit that mp3 player and you are dropped back to a shell. Any other file can be used instead of ~/.screenrc by pointing Screen at it with the -c option, e.g. screen -c /dev/null which I use in the rare case I want to start Screen as if no .screenrc existed. Selecting text, copying, pastingCopying works by selecting a start position and an end position for text to be copied. These are marked with the cursor's current position by pressing the <Space> key. Between two strokes the buffer can be navigated with the keys <h>, <j>, <k>, <l>, they work just as in the editor vim. But on most machines you can also use the <arrow keys> as well if you are not familiar with vim movement commands. And for the fans of emacs this default behavior can be changed in .screenrc. I suggest to consult the man page for the wealth of other movement commands available. The content of the buffer can then be pasted back into any other Screen window of the current session by typing C-a ]. So imagine you want to open a link pasted in an IRC channel, press C-a <Esc>, move to the beginning of the link, press <Space> and move on to the end for a second <Space>. Now open a new window with C-a c, type lynx C-a ]—and enjoy browsing! [edit] Advanced copyingOne can even access the file system to copy files into Screen, or concatenate selections in a Screen window into a file on the machine where Screen is running on. To copy a funny signature from a Usenet posting set Screen into copy mode with C-a <Esc>, select the text between two <Space> keystrokes and then set a buffer file in the current directory with C-a :bufferfile notes.txt. This file is written into (and overwritten if existing!) by C-a >. Note that C-a : sets Screen in the command mode and you actually type in Screen's status-bar. If no buffer file is given, Screen uses a default /tmp/screen-exchange, because this feature is primarily meant for exchanging data between Screen users on the same system. RegionsSimilar to vim, which not all of us reportedly prefer, we can use a single terminal window for more than one visible task. Screen can horizontally split into regions, each holding a different terminal.
To open a new region one types C-a S (capital s, please!).
To enter that newly created region we have to tab into it: C-a <Tab> Still nothing can be seen, but we can now cycle through our open terminals with C-a n or C-a p.
To close a region type C-a X. [edit] Resizing regions with CommandsTyping C-a : puts Screen into command mode and the status line at the bottom changes. Screen now accepts direct commands and resize 24 makes the currently focused region exactly 24 lines high. [edit] Problems with Screen being "frozen"?It is easy to confuse C-a S, which a uses a capital 'S' with C-a s, which uses a lower case 's'. The upper case command causes screen to be horizontally split (that is, with one region on top of the other), while the lower case command causes the parent terminal to freeze. To unfreeze the parent terminal, use the C-a q command. To remove this command, use the command sequence: bind s. This command can be entered at the colon (':') prompt or in the screen startup file. What happens is that Screen sends a ^S (xoff) to the screen, which freezes all output. The screen command C-a s is bound to the xoff command. You achieve the same effect in most terminals running bash by typing Ctrl-s. (Type Ctrl-q to undo this effect) You might have noticed that you can still navigate and use the other windows, and even create new ones after an accidental C-a s. To continue, use the C-a q (which is the xon command). For a proper lock of the session simply type C-a x and only your password gives you access again. You may also have a problem with Ctrl-z which sends a suspend to the terminal. Type once again to resume and/or turn off altogether with the stty command. It is also to be noted that when dealing with uppercase commands, you can't type the whole command (i.e C-a S) in a sequence. You must first C-a then Shift-s To start using Screen open a terminal and type screen. The optional startup message Depending on the setup of Screen you may be greeted by a startup message, but Gentoo has this usually disabled in /etc/screenrc with the line startup_message off. More about those settings later. If you press space or enter you are dropped into a login shell. The first sign of Screen successfully running can be discovered by typing C-a " which shows the list of terminals. At the moment there is only one. The Esc key exits that window. Alternatively, use C-a w to list them briefly in the window's title bar. A new terminal is created by typing C-a c. Typing C-a " again lists the terminals and shows the current one. Press Esc. After creating a new terminal it is useful to press C-a A and enter a name for the terminal. To create a named terminal directly, use C-a : and type screen <command>. With C-a n for next or C-a p for previous Screen you can cycle through those windows.
To detach Screen one can either use the brute-force method of clicking the x in the corner of the window, or the running instance of Screen can be properly detached with C-a d first. We are now dropped back into the shell that we started with in the beginning. At first we want to check if there is really a Screen-session running. These are listed by screen -ls. To access this one instance we re-attach with screen -R. Voilà, here we go again! This already explains the basic usage of Screen, and gives us a method to leave compiles running on a remote or local system without the need to keep a terminal open all the time, but Screen has more to offer: |