Softpanorama
May the source be with you, but remember the KISS principle ;-)

Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

GNU Screen -- an Orthodox Window Manager

A "must" tool for Unix Administrators

News See Also Recommended Links User Manual Reference Attaching to and detaching from screen sessions
Command line options .screenrc examples Splitting screen horizontally Splitting screen Vertically Unix script command
tmux Teraterm OFM Orthodox Editors VIM VNC
Unix History Tips Admin Horror Stories History of GNU Screen development Humor Etc

Introduction

GNU Screen is a simple, but at the same time very flexible and programmable windows manager. It is often called terminal multiplexer, but the key functionality of screen is in the area of windows management: creation, destruction and resizing of windows. For example it can split the console screen horizontally and display two windows at the same time. Screen is a Unix program (Cygwin version exists and is quite usable). For good Windows terminal emulator see Teraterm.

It can be called one of the most underappreciated Unix utilities, a real jewel of Unix programming art.

In addition to the ability to run many shell processes in a single terminal, screen provides classic windows management capabilities -- the ability to split terminal into regions (horizontal stripes of varying length, each containing its own session. What is also important is that like VNC screen provides the ability to detach the terminal emulator from the running programs and then reattach the same or new terminal to them.

This feature is enabled by default.

This means screen will keep shells and programs running in all windows that you opened even if you accidentally disconnected from the remote server or closed the terminal emulator. Like VNC screen also permits to share a terminal (in read-only mode) with someone else in real time. This permits to collaborate on a project by several remote users located in different places. It also frees administrator from waiting until a particular task ends. He/she can be connected to any number of servers, start a task, detach from the task, and the task keeps running. Then reattach later, check the status and intervene of needed.

You can start a job at the office and check for it completion at home. Also if you have complex setup you can do it once and reuse during the next connection, saving you time on recreating the environment you need for productive work.

An important feature of screen is that like VNC it provides the ability to detach the terminal emulator from the running programs and then reattach the same or new terminal to them. Then you can reattach to the session using screen -R preserving your environment, history and other session attributes. For sysadmin who administer multiple machines (especially if there multiple cooks in the kitchen) this is a big time saver.

Another important feature that screen it can be used for watching actions of others by connecting to somebody else screen session

screen -x

Screen has a certain architectural affinity to the orthodox file managers (OFM ), especially deco as well as orthodox editors like vi and THE (the power of command line).

Screen default prefix

Like in vi in screen you have to hit certain prefix to get to command line. The default prefix is Ctrl-A. For example key combination Ctrl-A C (Press will Ctrl-A, release Ctrl key and press C) opens new window.

This availability of command line operations and related scriptability via .screenrc file makes screen attractive to system administrators who value blend of power and simplicity provided by "orthodox" tools. Like in all orthodox utilities there is an extensive set of commands (mini-language) that can used to modify the behavior of screen.

Ctrl-a is called attention/command key and is similar to Esc in vi (you also can change Ctrl-A to another sequence, if you wish). This sequence presuppose that you are using Sun keyboard (with Ctrl in place of CapsLock) or switched Ctrl and CapsLock keys (in Windows you can use RandyRants SharpKeys -- which provides a nice interface to various registry hacks that remap one key into another, including remapping CapsLock to Ctrl. ).

Remap Ctrl to CapsLock. On Windows that can be done using RandyRants SharpKeys

If the colon (":") is entered after the attention key, then screen switches to command mode and you'll see a highlighted colon prompt at the bottom of the screen. After that, like in vi, you can enter commands that change the behavior of the screen and modify its current configuration. For example you can open and close windows, change size of windows, etc. For example you open new window also by typing command

Ctrl-A: screen

which is equivalent to the shortcut Ctrl-A C that we discussed above.

So shortcut Ctrl-A C and command Ctrl-A: screen are synonyms. This is just an association that is defined in .screenrc file - screen's dotfile. File .screenrc is a list of commands which are executed at startup. While by default screen is using the name .screenrc you can start screen using arbitrary screen's dotfile using option -c, for example

screen -c ~myhome/.screenrc_`uname`

This example demonstrated that you can have multiple .screenrc files and use the one that suits current environment (for example Linux, AIX, Solaris, etc) and the task in hand.

You can also execute predefined sequences of screen commands stored in the files (screen scripts) using the command source. One common application is the execution of the set of command creating a particular combination of windows and loading particular applications into each window. For example, you can load Perl in debugging mode on one window, vi in another and Perl POD browser in the third creating poor man IDE environment. For example

source .screenrc_perl

or

source ~myhome/perl.screenrc

That provides you with the flexibility to have several predefined sets of windows working on a particular task, the capability that improves your productivity dramatically as you can polish the arrangement and gradually connect a set of useful shortcuts as you gain experience with the environment (in the example above, working with Perl). System administrators can (and should) have a custom part of configuration encoded for particular hosts (that's the way I use screen at work) :

source ${HOME}/${HOST}.screenrc

Due to availability of command line interface and scriptability Screen can be considered to be a member of "orthodox" family of utilities which include orthodox file managers (mc, FAR, etc) and orthodox editors (vim, Xedit, THE, etc). Command line can be activated with Ctrl-A: after that you can enter any command from the screen command set to modify behavior of the screen or execute sets of commands (screen script) from particular file using command source.

A typical and probably the simplest application of this capability is to launch a predefined set of windows at screen startup., for example:

source $HOME/.screenrc # read in your normal screenrc
screen top # now start opening windows
screen -t irc epic # with the -t option it's possible to set the window title 
screen -t mail 8 mutt # you can also specify the window number to launch in 
screen -t messages 9 tail -f /var/log/messages

In X-windows world screen inspired several minimalist windows managers which usually are bungled with linux mini-distributions. Classic example of this genre is ratpoison (the name suggest that it is one of the few that not support mouse "out of principle" ;-).

Screen is portable and is an almost a standard utility on all flavors of Unix. It is often preinstalled by default in Linux distributions (for example, Suse 10). And it is easily installed in Solaris, AIX and HP-UX. For example Solaris 10 package can be found on sunfreeware.com:

screen-4.0.2-sol10-intel-local.gz Screen provides an ANSI/vt100 terminal emulator, which can multiplex up to 10 pseudo-terminals - installs in /usr/local. There are further configuration steps in the /usr/local/doc/screen/INSTALL. The etc and terminfo directories containing other relevant files are in /usr/local/doc/screen. The screen package may also require that you install the ncurses package.

Using it, you can run any number of console-based applications -- interactive command shells, curses-based applications, text editors, etc. -- within a single terminal. Many administrators who use screen open a dozen or even more sessions.

Modes of screen usage

Screen can be used in two ways (you can use both local and remote screen instances simultaneously by changing control character in local to say Ctrl-\ via .screenrc, see below):

  1. On local workstation (in this case you multiplex between terminal sessions opened in multiple screen windows). Many administrators use it as a terminal on steroids and have a window for each remote server they administer.
  2. Remotely (in this case you need first to connect to remote machine using, say ssh or telnet, run screen and then multiplex windows on this remote machine). In this case screen provide the ability to have serial local terminal sessions via single ssh or telnet connection (for example one root window and one non-root window).

A nested master-slave invocation of screen is also possible, but it is unclear how practical it is. See Jason White page and my screenrc and my slave screenrc by Tim Chambers. Here is how he explained this method in Slashdot post:

You run an "outer" screen session (the "slave" session) that in turn runs an "inner" (or "master") session. You use the regular escape sequence (Ctrl-A d) to detach from the master, and you map Ctrl-^ to be the control key for the slave session. If you press Ctrl-^ while using screen this way, you'll see one process in the slave session. It's running ssh-agent. That's the key to using ssh with screen. The slave's only purpose is to run ssh-agent. The master runs as a child of that. Consequently, all shells in the master session are running under the ssh-agent. Just run ssh-add from any master shell, and then all shells have your ssh identity.

As we mentioned above, after starting screen you need to open windows using the command Ctrl-a c. Every window in screen is identified by a unique number. The first window is usually numbered 0 (you can change this to one if you do not like counting from zero). For each created windows screen starts default shell. After that user for example can open remote session to a particular server and rename it to simplify recognition after switching to another (an optimal typical number of windows for one screen instance is around a dozen). You can use multiple screen instances each with its own set of servers to connect (DMZ servers, database servers, etc).

Minimal set of commands

Minimal set of commands necessary to use screen productively includes just five commands:

  1. Ctrl-a c to create a new window (Ctrl-a N -- lists the number of the active windows)
  2. Ctrl-a <number> to switch between them (Ctrl-a n, Ctrl-a p or Ctrl-a Ctrl-a will work too providing previous and next windows, but are less convenient and there are two of them instead of one)
  3. Ctrl-a " (windows) Show a list of active windows. You can navigate this list with the arrow keys (or vi-style, with j and k), and pick a window to activate by pressing Enter when it's highlighted. As this is one of the most often used commands you will be better off redefining this command as Ctrl-a space (see .screenrc examples on how to do that).

  4. Ctrl-a d. detach from current session. You can also detach just by closing the terminal emulator that contains the session. Neither of these actually end your session. All they do is unbind your session from the current terminal. All of the programs you started running within screen are still running. To reattach type screen -r from the command prompt
  5. Ctrl-a \ (quit) Kill all windows and terminate screen. You can close individual window by exiting shell with command exit.

There are also several more advanced features that can improve your productivity. Among them I would like first of all mention regions.

Regions can dramatically improves your productivity in pure command line environment. This feature turns screen in rudimentary windows manager able to create "strips" non-overlapping horizontal zones each of which corresponds to a separate shell window. To split the screen into two regions just press C-a S. The current window will split into two separate areas with the bottom area blank. To switch to the bottom part press C-a [Tab]. If you need to create a new shell in the new window, so press C-a c. If you want to see one of the existing sessions press Ctrl-a " and select the necessary session. You can create more regions by pressing C-a S again: each time the current "strip" will be split into two. Tabs display the active region shell name in its title bar. You can also switch between tabs being in a region, so e.g.: you have 4 tabs and 2 regions. Each region can display one of these tabs. A nice trick is that upper region can react on the change of the particular environment variable and display either file you are editing or the listing of the current directory. This arrangement is close for the OFM paradigm. You can change the size of each region by entering resize [size], where size is the number of lines.

Splitting the screen in two horizontal panes

The key additional feature of Screen that you need to master after mastering basic commands is split command.

Ctrl-a S (split, capital s, please!). Screen can horizontally by split into regions(panels), each holding a different terminal. After you split the window you need to move to the new region using Ctrl-a Tab (Press Ctrl-A release control key and only then press Tab key) and create a session in it using Ctrl-a-c.

Level 1 command set

Here is slightly more elaborate set of commands, which we will call Level 1 command set. It includes regions-related commands:

  1. Ctrl-a A (title) Allow the user to enter a name for the current window (useful fo naming each window according to the purpose (for example each can represent a different directory).

  2. Ctrl-a Ctrl-a (other) will switch you to whichever window you were using before the current one.
  3. Ctrl-a S (split, capital s, please!). Screen can horizontally by split into regions(panels), each holding a different terminal. After you split the window you need to move to the new region using Ctrl-a Tab (Press Ctrl-A release control key and only then press Tab key) and create a session in it using Ctrl-a-c.

  4. Ctrl-a <Tab> (focus) move the the next split window
  5. Ctrl-a X (remove) Close current region
  6. Ctrl-a N, where N is a number from 0 to 9, will switch to the corresponding window.
  7. Ctrl-a w lists windows in one like with the active marked by asterism. This is a noninteractive list and you cannot navigate it. Interactive list is by default assigned to Ctrl-a "
  8. Ctrl-a d. detach from current session. You can also detach just by closing the terminal emulator that contains the session. Neither of these actually end your session. All they do is unbind your session from the current terminal. All of the programs you started running within screen are still running. To reattach type screen -r
  9. Screen remembers a configurable number of scrollback lines. You can access the scrollback buffer by entering "copy mode", which is accomplished by typing Ctrl-a [. You can mark text anywhere in the scrollback buffer and paste it with Ctrl-a ]. Screen is also capable of logging to files.
  10. Screen has features that allow you to monitor a window for silence, useful, for example, for knowing when a compile has finished. To start or stop monitoring the current window for 30 seconds of silence, type Ctrl-a _; to start or stop monitoring a window for activity, type Ctrl-a M.
  11. To close sessions you need to to close each of your screen windows. Exit whatever programs or shells each is running, and they will go away. When the last program running inside screen is exited, screen itself will go away. You can forcefully quit screen with Ctrl-a Ctrl-\.

Extended list of screen commands

As you progress you "screen vocabulary" extends and in some point you can switch from Level 1 command set to Level 2 command set which includes several additional useful commands (and first of all bindkey command):

Ctrl-a ' (select)
Prompt for a window name or number to switch to.
Ctrl-a " (windowlist -b)
Present a list of all windows for selection.
Ctrl-a 0 (select 0)
... ...
Ctrl-a 9 (select 9)
Ctrl-a - (select -)
Switch to window number 0 - 9, or to the blank window.
Ctrl-a tab (focus)
Switch the input focus to the next region.
Ctrl-a Ctrl-a (other)
Toggle to the window displayed previously.
Note that this binding defaults to the command character typed twice, unless overridden. For instance, if you use the option "-e]x", this command becomes "]]".
Ctrl-a a (meta)
Send the command character (Ctrl-a) to window. See escape command.
Ctrl-a A (title)
Allow the user to enter a name for the current window (useful fo naming each window according to the purpose (for example each can represent a different directory).
Ctrl-a b
Ctrl-a Ctrl-b (break)
Send a break to window.
Ctrl-a B (pow_break)
Reopen the terminal line and send a break.
Ctrl-a c
Ctrl-a Ctrl-c (screen)
Create a new window with a shell and switch to that window.
Ctrl-a C (clear)
Clear the screen.
Ctrl-a d
Ctrl-a Ctrl-d (detach)
Detach screen from this terminal.
Ctrl-a D D (pow_detach)
Detach and logout.
Ctrl-a f
Ctrl-a Ctrl-f (flow)
Toggle flow on, off or auto.
Ctrl-a F (fit)
Resize the window to the current region size.
Ctrl-a Ctrl-g (vbell)
Toggles screen's visual bell mode.
Ctrl-a h (hardcopy)
Write a hardcopy of the current window to the file "hardcopy.n".
Ctrl-a H (log)
Begins/ends logging of the current window to the file "screenlog.n".
Ctrl-a i
Ctrl-a Ctrl-i (info)
Show info about this window.
Ctrl-a k
Ctrl-a Ctrl-k (kill)
Destroy current window.
Ctrl-a l
Ctrl-a Ctrl-l (redisplay)
Fully refresh current window.
Ctrl-a L (login)
Toggle this windows login slot. Available only if screen is configured to update the utmp database.
Ctrl-a m
Ctrl-a Ctrl-m (lastmsg)
Repeat the last message displayed in the message line.
Ctrl-a M (monitor)
Toggles monitoring of the current window.
Ctrl-a space
Ctrl-a n
Ctrl-a Ctrl-n (next)
Switch to the next window.
Ctrl-a N (number)
Show the number (and title) of the current window.
Ctrl-a backspace
Ctrl-a h
Ctrl-a p
Ctrl-a Ctrl-p (prev)
Switch to the previous window (opposite of Ctrl-a n).
Ctrl-a q
Ctrl-a Ctrl-q (xon)
Send a control-q to the current window.
Ctrl-a Q (only)
Delete all regions but the current one.
Ctrl-a r
Ctrl-a Ctrl-r (wrap)
Toggle the current window's line-wrap setting (turn the current window's automatic margins on and off).
Ctrl-a s
Ctrl-a Ctrl-s (xoff)
Send a control-s to the current window.
Ctrl-a S (split)
Split the current region into two new ones.
Ctrl-a t
Ctrl-a Ctrl-t (time)
Show system information.
Ctrl-a v (version)
Display the version and compilation date.
Ctrl-a Ctrl-v (digraph)
Enter digraph.
Ctrl-a w
Ctrl-a Ctrl-w (windows)
Show a list of window.
Ctrl-a W (width)
Toggle 80/132 columns.
Ctrl-a x
Ctrl-a Ctrl-x (lockscreen)
Lock this terminal.
Ctrl-a X (remove)
Kill the current region.
Ctrl-a z
Ctrl-a Ctrl-z (suspend)
Suspend screen. Your system must support BSD-style job-control.
Ctrl-a Z (reset)
Reset the virtual terminal to its "power-on" values.
Ctrl-a . (dumptermcap)
Write out a ".termcap" file.
Ctrl-a ? (help)
Show key bindings.
Ctrl-a Ctrl-\ (quit)
Kill all windows and terminate
screen.
Ctrl-a : (colon)
Enter command line mode.
Ctrl-a [
Ctrl-a Ctrl-[
Ctrl-a esc (copy)
Enter copy/scrollback mode.
Ctrl-a ] (paste .)
Write the contents of the paste buffer to the stdin queue of the current window.
Ctrl-a {
Ctrl-a } (history)
Copy and paste a previous (command) line.
Ctrl-a > (writebuf)
Write paste buffer to a file.
Ctrl-a < (readbuf)
Reads the screen-exchange file into the paste buffer.
Ctrl-a = (removebuf)
Removes the file used by Ctrl-a < and Ctrl-a >.
Ctrl-a , (license)
Shows where screen comes from, where it went to and why you can use it.
Ctrl-a _ (silence)
Start/stop monitoring the current window for inactivity.
Ctrl-a * (displays)
Show a listing of all currently attached displays.

Here are some examples of keyboard bindings:

bindkey -d # Show all of the default key bindings. The application mode entries are marked 
	with [A]. 
bindkey -k k1 select 1 # Makes the "F1" key switch to window one. 
bindkey -k F1 command # Makes the F11 (not F1!) key an alternative screen escape (besides `Ctrl-a'). 

Changing attention key sequence (Ctrl-A)

You can also easily change Ctrl-A (the default attention/command key sequence) to another sequence. This can be done either via putting command escape into .screenrc or via a switch when you start screen.

  1. -e xy specifies the command character to be x and the character generating a literal command character to y (when typed after the command character). The default is «Ctrl-a» and `a', which can be specified as "-e ^Aa". When creating a screen session, this option sets the default command character. In a multi-user session all users added will start off with this command character. But when attaching to an already running session, this option changes only the command character of the attaching user. This option is equivalent to either the commands «defescape» or «escape» respectively.

    If you invoked screen by using "screen -e ^Ww" you can see that ^W became attention/command key combination. So ^W-? gets the Help screen. Ctrl-A and then ? no longer worked.

  2. Adding co the .screenrc file using escape command is explained in the man page:

    escape xy

    Set the command character to x and the character generating a literal command character (by triggering the "meta" command) to y (similar to the -e option). Each argument is either a single character, a two-character sequence of the form "^x" (meaning "Ctrl-x"), a backslash followed by an octal number (specifying the ASCII code of the character), or a backslash followed by a second character, such as "\^" or "\\". The default is "^Aa".

    For example if you add

    escape ^\\ 

    into the .screenrc you will see that ^\ became attention key sequence instead of default ^A.

User friendly status line

It is also important to make screen more user friendly. In order better see what open windows you have you can do it by adding the following lines to .screenrc :

	1 hardstatus alwayslastline
	2 hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=
kw}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}
%Y-%m-%d %{W}%c %{g}]'

In his paper Screen Tips & Tricks Łukasz Olender suggests several other variants:

But so as not to get lost in these windows, I suggest you create tabs similar to those found in web browsers. You can do this by writing to your configuration file ~/.screenrc one of the following codes:

hardstatus alwayslastline
hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}
%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'

or

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}
(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m
%{W}%c %{g}]'

or

hardstatus alwayslastline
hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}
(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}]
%{=b C}[ %m/%d %c ]%{W}'

With the first code each tab will have a number, a name plus time and date. The second one will give you tabs that will be created in the center and the active tab will be highlighted in red and also have the hostname displayed. The last code will additionally display the processor usage. You can create your own codes but it is a rather specialized task - I refer you to the system manuals for more information.

You can combine ideas from those into you own status line that suits your need. But in any case it is important to improve visibility of windows by using this capability of screen.

RC file

Dr. Nikolai Bezroukov


Top updates

Bulletin Latest Past week Past month
Google Search


NEWS CONTENTS

Old News ;-)

2009 2008 2007 2006 2005 2004 2003 2002 2001 2000

Version 4.2.1 released

GNU Screen v.4.2.0

Vertical split is now  provided.

After six years since the last release and 27 years of existence of the project, a new release of GNU screen was presented by Amadeusz Sławiński, the new maintainer of the project, who was selected at the beginning of April.

He was previously was responsible for the support of a branch of screen on GitHub, which, compared to the official line contained 300 patches and enhancements.

Now all these changes are transferred back to to the main project and will be available in screen 5.

Release 4.2 was chosen as the 4.1 branch has already been created at the time of the merger. By its composition, the branch 4.2 similar 4.1. Packages with a new release is already available for users of Arch Linux and Debian Unstable (coming soon in Debian Testing).

the new version introduces support for layouts, added Association of funts installed the Windows, improved mouse support. Vertical split is now also provided. It also supports 256-color terminal, the ability to have multiple stories input, auto-completion of commands by pressing the tab key, initial support connection scripts-handlers, new commands (layout, group, unbindall, rendition, mousetrack).

As some of the changes affect compatibility with previous version (for example interaction with the back-end process rather than named pipes now uses sockets), soall sessions should be closed before performing the update.

Version 5, which is in words will contain substantial clean up of the code base. Some innovations developed  prepared outside the official branch might be included too, such as 256-color status bar, support of full-color palettes, and placement of banner at the top line and the possibility of moving status bar in the upper part.


From: Amadeusz Sławiński
Subject: [screen-devel] GNU Screen v.4.2.0
Date: Thu, 17 Apr 2014 00:53:22 +0200
Hello everyone,

it is my pleasure to announce release of GNU Screen v.4.2.0

available at http://download.savannah.gnu.org/releases/screen/
(I will also upload to ftp.gnu.org as soon as my access is authorized)

Many are probably using it due to their distributions packaging
development versions, so they know at least some of changes.
Short list of them:
 * layouts
 * window groups
 * better mouse support
 * vertical split
 * new and expanded commands

For full list of changes please check Changelog.


Please note that due to some changes it may be not possible to attach
to sessions created with older binaries.


With this I also plan to put v.4 into maintenance mode and start
developing v.5 with cleaned up source code, new features (some already
in development tree, currently outside of official repository):
 * 256 color hardstatus
 * truecolor
 * firstline hardstatus
 * top line caption
 and more

Amadeusz Slawinski

Re: [screen-devel] GNU Screen v.4.2.0


From: Axel Beckert
Subject: Re: [screen-devel] GNU Screen v.4.2.0
Date: Thu, 17 Apr 2014 09:10:41 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Amadeusz,

On Thu, Apr 17, 2014 at 12:53:22AM +0200, Amadeusz Sławiński wrote:
> it is my pleasure to announce release of GNU Screen v.4.2.0

Not a bad idea to _not_ call this 4.1.0 -- a version number floating
around with -dev suffixes in quite many distros. :-)

Good to see that you got commit access, etc.

> Please note that due to some changes it may be not possible to attach
> to sessions created with older binaries.

There's a patch for that at
http://patch-tracker.debian.org/patch/series/view/screen/4.1.0~20120320gitdb59704-9/60-644788-screen-4.1.0-4.0.3-interoperability.patch

Feel free to include it in 4.2.1. (Not tried if it still applies, but
I will try soon. :-)

P.S.: I recently got one report that someone uses Screen's Zmodem
support for some embedded board (Soekris) maintenance. No further
details though as I didn't get that first hand.

                Kind regards, Axel

Re: [screen-devel] GNU Screen v.4.2.0


From: Jürgen Weigert
Subject: Re: [screen-devel] GNU Screen v.4.2.0
Date: Thu, 17 Apr 2014 15:44:05 +0200

config.h.in is generated when you run autogen.sh
 
Several other autogenerated files are also no longer included. Which is a good thing for maintenance, as they can no longer go out of sync.

 
I patched the specfile to run autogen.sh and make depend. The later is a horrible hack. It patches the Makefile, and would fail if the osdef.h and comm.h are not yet generated.
 


 
On Thu, Apr 17, 2014 at 2:22 PM, Jeroen Roovers <address@hidden> wrote:
 
On Thu, 17 Apr 2014 00:53:22 +0200
Amadeusz Sławiński <address@hidden> wrote:

> it is my pleasure to announce release of GNU Screen v.4.2.0

 
Very nice.
 

> available at http://download.savannah.gnu.org/releases/screen/
> (I will also upload to ftp.gnu.org as soon as my access is authorized)

 
config.h.in is missing from the tarball.

Re: [screen-devel] GNU Screen v.4.2.0


From: Jürgen Weigert
Subject: Re: [screen-devel] GNU Screen v.4.2.0
Date: Thu, 17 Apr 2014 15:52:37 +0200

Amadeusz et all:
 
At opensuse, we have a wagonload of patches, that I'd like to offer for your review and merge into upstream.
See attached.

  * added msg_version_3.patch (ouch, incompatible protocol, to be upstreamed asap)
  * keep screen-man-loginshell.diff (to be upstreamed)
  * keep term_too_long.diff (savannah#30880, to be upstreamed)
  * keep use_locale.diff (from address@hidden 2012, check?)
  * keep screen-4.0.3-ipv6.patch (builtin telnet, to be upstreamed)
  * keep screen_enhance_windows_list.patch (to be upstreamed)
  * keep screen-poll-zombies.patch (to be upstreamed)
  * keep xX_string_escape.patch (renamed from show_all_active.patch, to be upstreamed)
  * keep sort_command.patch (from trenn 2011, to be upstreamed)
  * keep libtinfo.diff (from coolo 2011, why exactly?)
  * keep global_screenrc.patch (renamed from screen-4.0.2.dif)


 
CCed Thomas, Michael: submit requests 230477 and 230482
 
 sent to Factory and 13.1:Update
 

Re: [screen-devel] GNU Screen v.4.2.0


From: Amadeusz Sławiński
Subject: Re: [screen-devel] GNU Screen v.4.2.0
Date: Fri, 18 Apr 2014 18:54:03 +0200

On Thu, 17 Apr 2014 15:52:37 +0200
Jürgen Weigert <address@hidden> wrote:

> Amadeusz et all:
> At opensuse, we have a wagonload of patches, that I'd like to offer
> for your review and merge into upstream.

If anyone else has any patches, please share ;)

>
> * added msg_version_3.patch (ouch, incompatible protocol, to be
> upstreamed asap)

on screen-v4 branch

> * keep screen-man-loginshell.diff (to be upstreamed)
> * keep term_too_long.diff (savannah#30880, to be upstreamed)

I used a bit different version based on what I found in manpages
http://git.savannah.gnu.org/cgit/screen.git/commit/?h=screen-v4&id=44020241d033555e8e90fad3c88617dce1aed0bb

> * keep use_locale.diff (from address@hidden 2012, check?)
> * keep screen-4.0.3-ipv6.patch (builtin telnet, to be upstreamed)
> * keep screen_enhance_windows_list.patch (to be upstreamed)
> * keep screen-poll-zombies.patch (to be upstreamed)
> * keep xX_string_escape.patch (renamed from show_all_active.patch,
> to be upstreamed)
> * keep sort_command.patch (from trenn 2011, to be upstreamed)
> * keep libtinfo.diff (from coolo 2011, why exactly?)

For this I used patch from gentoo, as it seems to provide better
checks, it checks for alternative libraries to use instead of curses one

> * keep global_screenrc.patch (renamed from screen-4.0.2.dif)

With regards to rest of the patches, I would like to merge them when I
start merging my tree (some of them are already in there).

Amadeusz

Re: [screen-devel] GNU Screen v.4.2.0


From: Axel Beckert
Subject: Re: [screen-devel] GNU Screen v.4.2.0
Date: Fri, 18 Apr 2014 22:38:54 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

On Fri, Apr 18, 2014 at 06:54:03PM +0200, Amadeusz Sławiński wrote:
> On Thu, 17 Apr 2014 15:52:37 +0200
> > At opensuse, we have a wagonload of patches, that I'd like to offer
> > for your review and merge into upstream.

Same counts for Debian as mentioned before. :-)

> If anyone else has any patches, please share ;)

The patches I used against 4.2.0 for the Debian package (available in
Debian Experimental for now) should be available for easy reviewing at
http://patch-tracker.debian.org/package/screen/4.2.0-1 but Debian's
patch tracker seems down for the moment. :-(

A less comfortable variant is at
http://anonscm.debian.org/gitweb/?p=collab-maint/screen.git;a=tree;f=debian/patches

Most of the patches should be suitable for upstream inclusion.

Solely those which change the size of some string lengths (user name,
$TERM, etc.) may cause issues as they may change the internal protocol
between client and server processs as far as I understood it.

The patch 80EXP_session_creation_time.patch should be regarded as
feature as it changes default behaviour. It sorts "screen -ls" output
by creation time and also affects "screen -rr" and friends -- IIRC it
makes them more deterministic. Maybe something for the development
branch and the 5.x releases.

                Kind regards, Axel

Re: [screen-devel] GNU Screen v.4.2.0


From: Amadeusz Sławiński
Subject: Re: [screen-devel] GNU Screen v.4.2.0
Date: Fri, 25 Apr 2014 15:09:30 +0200

> A less comfortable variant is at
> http://anonscm.debian.org/gitweb/?p=collab-maint/screen.git;a=tree;f=debian/patches
> 
> Most of the patches should be suitable for upstream inclusion.
> 
> Solely those which change the size of some string lengths (user name,
> $TERM, etc.) may cause issues as they may change the internal protocol
> between client and server processs as far as I understood it.
> 
> The patch 80EXP_session_creation_time.patch should be regarded as
> feature as it changes default behaviour. It sorts "screen -ls" output
> by creation time and also affects "screen -rr" and friends -- IIRC it
> makes them more deterministic. Maybe something for the development
> branch and the 5.x releases.
> 
>               Kind regards, Axel

Hey,

I've went through debian patches and I've applied most of them.
Here are the ones I've not applied with comments.

11replace_doc_paths.patch - seems debian specific

13split_info_files.patch - also debian specific?

26source_encoding.patch - cosmetic change for source code

45suppress_remap.patch - I've checked the logs and it seems like there
was already a revert of revert... are you sure it doesn't break
anything?

47screen-cc.patch - I will first check patches from Fedora, instead of
monolithic one ;)

48screen-ipv6.patch - it's a feature -> v5

49long-usernames.patch - already fixed

50increase-max-TERM-length.patch - already fixed

58-show-encoding-hardstatus.patch - feature -> v5

60-644788-screen-4.1.0-4.0.3-interoperability.patch - still not sure
about this one

80EXP_session_creation_time.patch - not applied -> v5

Amadeusz


 

[Jan 23, 2012] A guide to GNU Screen by Steve ‘Ashcrow’ Milner and Anderson Silva

October 5, 2007 Red Hat Magazine

Sharing a session with others

Another great application of Screen is to allow other people to login to your station and to watch the work you are doing. It is a great way to teach someone how to do things on the shell.

Setup to allow screen to be shared

  1. As root: chmod u+s /usr/bin/screen (Screen has to be SUID if you want to share a term between two users.)
    Note: SUID allows an executable to be run by the owner of that file, instead of with the user's own permission. There are some security concerns when doing this, so use this tip at your own discretion.
  2. chmod 755 /var/run/screen
  3. Log out of root, and run Screen as the user who is going to share the session:
    screen
  4. Press Ctrl+a, then type :multiuser on and press Enter.
  5. Press Ctrl+a, then type :acladd steve (”steve” is the username of the person who will connect to your screen session).

Connecting to the shared screen:

  1. SSH into the workstation that you are going to watch the screen session on.
  2. On your terminal type: screen -x anderson/ (”anderson” is the username of the person who is sharing the screen session. You need the / at the end.).

And now both users (from the host and guest) will be sharing a screen session and can run commands on the terminal.

Working from multiple locations

Let's say you have a screen session open at work with X number of windows on it. Within those screens you may be running an IRC client, an SSH connection to the web server, and your favorite text-based email client. It's 5 p.m. and you have to go home, but you still have work left to do.

Without Screen you would probably go home, VPN into your company's network, and fire up all the shells you need to keep working from home. With Screen, life gets a little easier.

You can simply SSH into your workstation at work and list your available screen sessions with the command:

screen -ls

And connect to the sessions you were running at work with the command:

screen -x screen_session_name

This way screen will let you pick things up exactly from where you left off.

Applications to make Screen your window manager

Now that you have seen what Screen can do for you, you probably are wondering how to make it your main interaction point, like a terminal window manager.

Let's start with IRC, a very common and popular chat system. Instead of using a graphical client like Pidgin, install Irssi. Irssi sports a slick console interface, tons of add-ons and scripts, and can be enhanced with Perl. It's even theme-able!

Another important part of any user's setup is email. Today most people use graphical clients such as Thunderbird, Evolution, or Sylpheed. My favorite client happens to run in a terminal: Mutt. While Mutt isn't the easiest client in the world to set up, it sure is a joy to use. You can even use your favorite console text editor for doing emails.

Speaking of favorite text editors, there is a good chance that you work on some code projects or configurations. Instead of using gedit/kedit or powering up a heavy IDE such as Eclipse, you can pick up on Vim. Vim is a powerful text editor which, as is stated on the Vim website, could be considered an entire IDE in itself and sports syntax coloring in over 200 programming languages. If Vim doesn't fit your style, there is always emacs, nano, or JOE.

Now all you need you need to do is edit your ~/.screenrc to meet your needs.

My ~/.screenrc looks like the following:

	1 hardstatus alwayslastline
	2 hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=
kw}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}
%Y-%m-%d %{W}%c %{g}]‘
	3
	4 # Default screens
	5 screen -t shell1	0
	6 screen -t shell2	1
	7 screen -t server	2 	sh me@myserver
	8 screen -t IRC	7	irssi
	9 screen -t Mail	8	mutt

Once you get used to the shortcuts in GNU screen, not only will your desktop become more organized (due to the lower number of open windows), but your efficiency as a developer or system administrator will increase not only at work but at your home office as well.

Richard :

Just like abeowitz, I’m wondering whether it is possible to use screen to send commands to multiple screens.

According the documentation this should be possible with the “at” command, but I don’t get it to work.

So the command sequence:
C-a :at # date
Should result in a date executed on all windows (to my understanding, but the result I get is:
“: at: at least two arguments required”)

OTOH according the TODO file at:
ftp://ftp.uni-erlangen.de/pub/utilities/screen/screen-4.0.3.tar.gz
states: “- type into several windows at once (for cluster admins)”
That file has been changed in august 2003 for the last time…

Hopefully someone reading this article knows how to use the at command???

Hey Richard!:

With the ‘at’ command, you can send commands to other windows that have to be typed when you press C-a :
This changes the title of a window in a certain screen session:
screen -X at 1 title blublublu

Richard:

A way to broadcast commands to all windows is the following:
^a:at \# stuff “ls12?

Thanks goes to Michael, (one of the screen devs) who provided this information to me.The command above should read: double quote ls backslash zero twelve double quote. Somehow the parser removes the blackslash zero. One more try:
^a:at \# stuff “ls\\12″

Rob Nichols:

This is a great intro. I’ve used screen for many years. (Just stopped to count. I think it’s been a decade!) However, I’d never bothered with learning about the hardstatus line until this article. It’s a nice addition. Thanks!

P.S. I think there are two mistakes in the example given. Again, this is my first foray in screen’s string escapes, so I might be way off. I think “%{=kw}” should have a space, as “%{= kw}”. Without this change on my system windows before the current are green instead of white. I also think there is an extra “%?” before the the closing “]” on the window list. This made no difference on my system. Here’s a version with these changes.

hardstatus string ‘%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]‘

John:

I’ve used Screen for more than a decade. For years now I’ve used it to keep open ssh sessions to various systems, doing things like tailing logs and such, and disconnecting then reconnecting when necessary. My latest session has been running upwards of 2 years, only ever bringing it down for critical patching. Sometimes I connect to the same session from multiple windows, displaying different screen “windows” for multiple views. I also use an always on statis as well.

The few modifications I’ve made are to increase the MAXWIN param to allow for more windows, and change the command key to ^w so I don’t have to unlearn my emacs ^a habits.

John Pye:

One good use of Screen is when performing remote updates of systems using apt-get or yum. You can start the update going, then disconnect, then come back later and check that it finished OK. If your remote connection goes down, it doesn’t mess everything up. Also, using the screen ‘logging’ function, you can keep a full history of the update, and check it for error messages that you might have missed.

[Jan 23, 2012] Using GNU Screen

Here's a list of all the commands we've covered:

[Oct 19, 2010] Screen - s5h.net

[Aug 06, 2010] Re Vertical split in GNU screen

Aug 06, 2010 | Cygwin list

flo@neotek.fr

On Fri, Aug 06, 2010 at 03:50:28PM +0200, flo wrote:
Hi, i'm new with mailing-lists use! i'd like to re-talk about a feature with cygwin screen! How can we add the marvellous "Vertical split in GNU screen" with cygwin? I know there were a talk about that between Jeenu V <jeenuv at gmail dot com> and Andrew Schulman <schulman dot andrew at epamail dot epa dot gov> the 19 Apr 2010! Thanks in advance for somebody answer! If i'm not at the right place to talk about this or if i don't use this list in the good way, please don't shout at me, just show me!

Florent LOTTIN
 

Andrew Schulman-3

this post by flo@neotek.fr

> Hi, i'm new with mailing-lists use!
> i'd like to re-talk about a feature with cygwin screen! How can we add
> the marvellous "Vertical split in GNU screen" with cygwin?
> I know there were a talk about that between Jeenu V <jeenuv at gmail
> dot com> and Andrew Schulman <schulman dot andrew at epamail dot epa
> dot gov> the 19 Apr 2010!
> Thanks in advance for somebody answer!
> If i'm not at the right place to talk about this or if i don't use
> this list in the good way, please don't shout at me, just show me!
> Florent LOTTIN

...[show rest of quote]


Hi Florent.  There is a patch that's been available for a while, that adds
vertical split support to screen.  I believe that Debian, Ubuntu, and
probably others already incorporate it into their official screen packages.

I remember the exchange with Jeenu, and after that I did go get the patch,
build screen with it for Cygwin, and try it out.  What I found, if I
remember right, is that I saw a lot of what I considered strange behavior,
and very little documentation or help about how the vertical split feature
is supposed to work.  It didn't seem to me to be working very well, so I
put it aside.

If people would like to try out the patched version, I can post it as a
test release.  Maybe you can tell me if the vertical split feature is
working the way it's supposed to.

Andrew.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

flo@neotek.fr
Thanks a lot for your quick answer! I will be pleased if you could
post the version of Screen with vsplit patch  as a test release
because i didn't try to compile for cygwin yet!
I will try it and give my feedback! I'm on winxp sp3!
Rgds,
Florent..

2010/8/6 Andrew Schulman <[hidden email]>:


>> Hi, i'm new with mailing-lists use!
>> i'd like to re-talk about a feature with cygwin screen! How can we add
>> the marvellous "Vertical split in GNU screen" with cygwin?
>> I know there were a talk about that between Jeenu V <jeenuv at gmail
>> dot com> and Andrew Schulman <schulman dot andrew at epamail dot epa
>> dot gov> the 19 Apr 2010!
>> Thanks in advance for somebody answer!
>> If i'm not at the right place to talk about this or if i don't use
>> this list in the good way, please don't shout at me, just show me!
>> Florent LOTTIN
>
> Hi Florent.  There is a patch that's been available for a while, that adds
> vertical split support to screen.  I believe that Debian, Ubuntu, and
> probably others already incorporate it into their official screen packages.
>
> I remember the exchange with Jeenu, and after that I did go get the patch,
> build screen with it for Cygwin, and try it out.  What I found, if I
> remember right, is that I saw a lot of what I considered strange behavior,
> and very little documentation or help about how the vertical split feature
> is supposed to work.  It didn't seem to me to be working very well, so I
> put it aside.
>
> If people would like to try out the patched version, I can post it as a
> test release.  Maybe you can tell me if the vertical split feature is
> working the way it's supposed to.
>
> Andrew.
 

...[show rest of quote]

[Oct 19, 2010] Make GNU Screen Your Default Shell

George's tip actually makes a lot of sense ! In Linux you can put in cron an automatic restart of screen in case of reboot using @reboot.
October 18 2010 | ServerWatch.com

Celsius1414:

Or better yet, especially if you're on a multi-user system, edit ~/.screenrc instead.

george >: -[This is an interesting idea --NNB]

If I understand your write-up then you'll have a ton of screen sessions on your system because everytime you log in you'll create another screen.

Instead, I first login and create a screen session called main using screen -S main

I have the end of my .bash_profile set to run screen -D -R main. That way whenever I log in it'll automatically Disconnect then Reconnect my screen session - bingo bango bongo - only one screen session running at a time.

As a funny bonus I now know everytime the server's rebooted because my main screen session goes away and I have to restart it.

By archtaku :

I do something similar on my laptop and netbook. There's an environment variable that is set in a shell which was started inside a GNU Screen session, which is called STY. By checking if the value of $STY is zero-length, one can easily tell whether or not you are already within a screen session, and launch screen if you're not:

[ -z "$STY" ] && screen

On my office workstation I also launch screen this way, but since I often login to it remotely (unlike my laptop) I also check to see if SSH_CONNECTION is zero-length:

[ -z "$STY" ] && [ -z "$SSH_CONNECTION" ] && screen

This means I still need to launch screen manually when logging in remotely, but I often leave a screen session running on my workstation (because I'm in the middle of something) and resume it once I login.

Edo:

Maybe I'm a bit "old fashion" but I like screenie http://goo.gl/xVj4

Screenie is a small and lightweight GNU screen(1) wrapper that is designed to be a session handler that simplifies the process of administrating detached jobs by providing an interactive menu.

Reply to this commentBy pbrisbin October 19 2010 8:39 PMPDT Nice post.

I actually use a combination of environment variables and bash aliases to make `irssi` launch or reconnect an in-screen instance of irssi; similarly, `rtorrent` launches or reconnects an in-screen instance of rtorrent.

I also have a main screen session that opens when I just type `screen`, maybe I'll start launching/reconnecting that one at login through .bashrc like you suggest.

If you're interested, in my method: http://pbrisbin.com/posts/screen_tricks/

[Oct 19, 2010] Taking Command of the Terminal with GNU Screen by Joe 'Zonker' Brockmeier

February 11, 2010 | linux.com

Attaching and Detaching from Screen

One of the most powerful features of screen is the ability to detach and attach to running sessions. If you tend to work from several machines, it might be a good habit to start an instance of screen when you log in. Then if you're at a different system you can simply attach or re-attach to the running session and resume where you left off.

Note that you can also share a screen session, so it's not necessary to detach from a session in order to log into the same session from another location. So, for example, if you've logged into a system remotely using SSH and then started a screen session, you could then go to another computer and attach to the same session.

To see which sessions are running, use screen -ls. This will display all running sessions, and the process IDs (PIDs). If you have more than one session running, you will need to know the PID to attach or reattach to an existing session. To detach a session, use Ctrl-a d. If that's the only session running, you can reattach with Ctrl-a r If more than one session is detached, you'll need to run Ctrl-a r XXXXX where XXXXX is the PID.

To connect to a session that's still attached, use Ctrl-a x XXXXX instead. This will let you re-attach to an existing session without any problems.

Can I have a Copy of That?

Want a quick and dirty way to take notes of what's on your screen? Yep, there's a command for that. Run Ctrl-a h and screen will save a text file called "hardcopy.n" in your current directory that has all of the existing text. Want to get a quick snapshot of the top output on a system? Just run Ctrl-a h and there you go.

You can also save a log of what's going on in a window by using Ctrl-a H. This will create a file called screenlog.0 in the current directory. Note that it may have limited usefulness if you're doing something like editing a file in Vim, and the output can look pretty odd if you're doing much more than entering a few simple commands. To close a screenlog, use Ctrl-a H again.

Note if you want a quick glance at the system info, including hostname, system load, and system time, you can get that with Ctrl-a t.

Simplifying Screen with Byobu

If the screen commands seem a bit too arcane to memorize, don't worry. You can tap the power of GNU Screen in a slightly more user-friendly package called byobu. Basically, byobu is a souped-up screen profile originally developed for Ubuntu. Not using Ubuntu? No problem, you can find RPMs or a tarball with the profiles to install on other Linux distros or Unix systems that don't feature a native package.

Note that byobu doesn't actually do anything to screen itself. It's an elaborate (and pretty groovy) screen configuration customization. You could do something similar on your own by hacking your ~/.screenrc, but the byobu maintainers have already done it for you.

Since most of byobu is self-explanatory, I won't go into great detail about using it. You can launch byobu by running byobu. You'll see a shell prompt plus a few lines at the bottom of the screen with additional information about your system, such as the system CPUs, uptime, and system time. To get a quick help menu, hit F9 and then use the Help entry. Most of the commands you would use most frequently are assigned F keys as well. Creating a new window is F2, cycling between windows is F3 and F4, and detaching from a session is F6. To re-title a window use F8, and if you want to lock the screen use F12.

The only downside to byobu is that it's not going to be on all systems, and in a pinch it may help to know your way around plain-vanilla screen rather than byobu.

For an easy reference, here's a list of the most common screen commands that you'll want to know. This isn't exhaustive, but it should be enough for most users to get started using screen happily for most use cases.

Finally, if you want help on GNU Screen, use the man page (man screen) and its built-in help with Ctrl-a :help. Screen has quite a few advanced options that are beyond an introductory tutorial, so be sure to check out the man page when you have the basics down.

[Jun 27, 2010] Screen - s5h.net

Automation

It took a while but I thought there would be a way to send some data to a pts to prevent it from timing a session out, although this path proved too complex through /dev/pts and unfruitful for me. GNU Screen does have a mechanism to do this however, though -X. For example, from cron, I've configured this, to send the .info command to a screen session:

1       1       *       *       *       /usr/local/bin.sun4/screen -rd talker -X stuff '^U.info^M'

This, tells the session named 'talker' to stuff the text '.info' into the session. Replace ^U and ^M with ctrl-v followed by u/m (carriage return character), this simulates the user clearing the line and typing .info followed by the return key.

Automation can be further enhanced though the -p argument.

Screen makes it very handy if you want to automate both the left and right hand site of an application (simulate the user and server).

scroll back

Scroll back isn't as friendly as in vim, but there is some overlap with the key strokes

keystroke action
h Move the cursor left by one character
j Move the cursor down by one line
k Move the cursor up by one line
l Move the cursor right by one character
0/^ Move to the beginning of the current line
$ Move to the end of the current line
g Move to the begging of the buffer
G Moves to the specified line (defaults to the end of the buffer)
C-u Scrolls a half page up
C-b Scrolls a full page up
C-d Scrolls a half page down
C-f Scrolls the full page down

marking

keystroke purpose
v Sets line numbers
a/A Press this after selecting text and the following space will

append marked text to the buffer rather than overwriting the contents, uppercase to toggle

> This writes the buffer to the screen-exchange file where the

contents can be read later.

x reposition the start of the marker

sessions

Suppose you want a set of sessions created to various hosts, one way to do that might be something along the lines of:

$ screen -d -m -S mega
$ for i in host1 host2 host3 ; do screen -rd mega -X screen -t $i ssh $i ; done;

This will create three sessions to host[1..3] with the title of host[1..3].

This is perhaps one of the most useful features that I've found with screen (besides all the other useful things of course). There is a maximum of 40 windows allowed with the default build of screen. If you want to change this, reconfigure your screen build with -DMAXWIN=255, or edit the config and set the MAXWIN there.

When using the screen command it might be worth noting the following very useful parameters

parameter description
-T Sets the TERM environment, such as vt100, xterm, xterm-color and xterm-256color. This is highly useful if the default TERM does not support the bells and whistles of xterm
-M Monitors the window for activity
-t Sets the title of the window

pre-selection

In the previous example we have a number of screen windows with title host1. Should you wish to select for example host1 and list a file, then write something to the terminal you might do something like this:

$ screen -rd mega -p host1 -X stuff 'ls -al ~/.screenrc^Mecho joy^M'

I hope this gives you an idea of how even more useful screen can be than it first appears!

I often use pre-selection when the window list cannot be searched through, for example rather than scan through 40 window titles with my eye balls I can drop out of the screen session and use screen -r -p name to jump to the window title name.

[Jun 27, 2010] switching from gnu screen to tmux (updated)

Linux~ized

update #1: upstream accepted my patch, so the next tmux release will provide window-status-alert-{attr,fg,bg} Only difference is the use of alert instead of flagged. It sounds better anyway I’ll adjust my patch on 1.2 as well

update #2 [2010/05/17]: uploaded my updated config file, now using ` as my prefix key

I gave tmux a try yesterday.

Clean config file, thorough documentation and a few nice touches here and there (i.e. better, persistent window splitting) make it a nice alternative to screen, but the biggest difference lies in memory usage. Screen can easily eat up to 40-50mb with just a few windows open, but tmux has yet to reach the 10mb mark!

You may argue that ram is cheap these days, but when you’re on a 360mb VPS ram matters

I did find a few bugs/annoyances, for instance if you add set-option -g default-terminal “screen-256color” in your config file, tmux stops evaluating the #T variable.

I hacked my way out of this one by adding the following in my .bash_profile instead:

[[ $TERM == "screen" ]] && export -p TERM="screen-256color"

Turns out that’s not tmux’s fault but bash’s, I’ll have to create a patch for that as well If you have the same issue, you can use the above hack as a temporary fix.

Also version 1.2 does not provide a way for you to customize the colors used on window titles with alerts (either monitored or when the bell is active), but I patched that and sent it upstream

You can find an ebuild with the patch in my overlay, wirelay (layman -a wirelay ).

The patch was accepted upstream so it’ll be in the next release.

# ` is an interesting key for a prefix
set-option -g prefix `
# set-option -g prefix C-a

unbind-key C-b
bind-key C-a last-window
bind-key ` last-window
bind-key a send-prefix

# we might need ` at some point, allow switching
# we can also send the prefix char with `-a
bind-key F11 set-option -g prefix C-a
bind-key F12 set-option -g prefix `

# 0 is too far from `
set -g base-index 1

# set-option -g default-terminal "screen-256color"
set-option -g mouse-select-pane on
set-option -g status-keys vi
set-option -g bell-action any
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name,active (or not)
set-option -g visual-bell on

setw -g mode-keys vi
setw -g mode-mouse on
setw -g monitor-activity on

bind e previous-window
bind f next-window
bind j up-pane
bind k down-pane

set-option -g status-utf8 on
# set-option -g status-justify centre
set-option -g status-justify left
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-left-length 40

set-option -g pane-active-border-fg green
set-option -g pane-active-border-bg black
set-option -g pane-border-fg white
set-option -g pane-border-bg black

set-option -g message-fg black
set-option -g message-bg green

#setw -g mode-bg black

setw -g window-status-bg black
setw -g window-status-current-fg green
setw -g window-status-alert-attr default
setw -g window-status-alert-fg yellow

set -g status-left '#[fg=red]#H#[fg=green]:#[fg=white]#S #[fg=green]][#[default]'

# set -g status-right '#[fg=green]][#[fg=white] #T #[fg=green]][ #[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default]'
set -g status-right '#[fg=green]][ #[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default]'

set -g history-limit 4096

# `+r reloads the configuration, handy
bind r source-file ~/.tmux.conf

Selected Comments

Dan Douglas:

I gave tmux a serious effort a few months ago. There’s a few things that made me switch back to screen.

1) Tmux doesn’t support mouse dragging. If you use Vim in Screen you can “set ttymouse=xterm2″ in .vimrc and you can drag visual selections and have them show up in your X copy buffer, and it defines a protected region for the area you actually want to select. You can even drag to resize vim’s split windows. None of that works in Tmux. If you do vertical splitting, tmux it selects text from both sides of the split, and with line numbering on it selects the numbers unless you :set nonumber. Yes, just like screen Tmux has it’s own copy/paste system – but it’s slow to use. You end up with 3 different buffers for X, Screen, and your editor and it becomes a pain especially when working from putty.

2) Tmux handles windows very differently from screen. What Vim calls “tabs”, tmux calls “windows”, what Vim and screen call “windows”, tmux calls “panes”, and what Vim and Screen call “buffers”, tmux has no equivalent – which is has been a huge pain in the ass until possibly the latest version of Tmux which added the join-pane command which I haven’t tried since it was released. Still, I find working with it in that way a bit unnatural.

Clearly Tmux looks like the better long-term solution. It’s configuration actually makes sense and it’s session handling are superior to screen.

Screen development is stalled and the live ebuild from the berkano overlay with the vertical split patch hasn’t been building for the last 6 months or so. Since switching to xmonad as a tiling wm really the only thing I need is the detachable sessions support, which Screen does just fine.

wired :

You probably had mouse-select-pane set to on. That way, tmux grabs the mouse click. You can still hold down the shift key to mark things by clicking and dragging Not sure if you can make tmux define a protected region though.

Join-pane and break-pane work as advertised in 1.2.

I don’t use splitting much on localhost either, since I’m using the awesome window manager, but splitting is very useful when doing work over ssh

Dan Douglas:

Yeah splitting is definitely useful over ssh. That’s primarily why I started using it.

I tried turning mouse-select-pane off. I had a chat with one of the tmux devs on irc a few months ago and apparently the problem is simply that they don’t implement that yet. My workaround was setting a hotkey in vim to turn line numbers on and off so it’s possible to copy/paste between a browser window without having to abuse xclip too much.

I didn’t realize Screen was that hard on resources either. Kinda stinks. I’ve been using Konsole too which apparently isn’t so lightweight. I like it though since I have kde installed anyway and has always worked flawlessly.

krigstask:

I’ve switched to tmux recently too, but I’m not that advanced user, so the only thing bothering me is that I can’t figure out how to do something similar to `screen -RD`. If remote box has been rebooted, I don’t want to run `tmux attach`, then see it failing, run `tmux` and then reattach to it again. I think it could be somehow worked around, but didn’t succed myself.

wired:

you could define an alias (or write a small bash script) that does that automatically:

alias mytmux="tmux a -d || tmux"

Alex:

The biggest memory saving I made on my machine recently was switching away from gnome-terminal to urxvt(d). I’ve never really noticed much of a memory issue with screen although I do wish it was easier to script/configure. I shall check out tmux when I next have a spare few hours

sylware :

gnu screen and tmux are bloatware.

I swtiched to dtach. http://dtach.sourceforge.net/

wired:

well, if your needs are satisfied with dtach, then sure, the others are bloatware for you! I, on the other hand, actually use their features

ΤΖΩΤΖΙΟΥ:

I don’t know why your ‘screen’ use is bloated. This is from a 256 MiB home server:

F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
1 S tzot 3215 1 0 80 0 – 1319 ? May01 ? 00:00:03 SCREEN -A -a -U
0 S tzot 32215 32214 0 80 0 – 1018 ? 11:32 pts/0 00:00:00 screen -A -a -U -D -r 321

Its size is 100×25, four bash/dash sessions plus one mc session, no ~/.screenrc, the default /etc/screenrc has defscrollback 1000. The system runs gentoo on a Geode LX processor.

fb:

I originally switched from screen to tmux because screen has problems with terminals larger than 256 chars in width. Maybe there are patches around, but I couldn’t find a solution back then (I don’t think they solved it until now?). Anyway, tmux works find with >256 char wide terminals . And soon I realized how much “better” tmux is.

nice seeing you switching to tmux too

ed:

screen is really cool, and does somethings that I’ve yet to find counterparts to with tmux, such as the -x option:

http://www.s5h.net/wiki/Screen#Automation

How did you measure the RAM usage? Did you have the same scrollback in tmux as screen?

nm:

The equivalent of -x is the default with tmux unless you explicitly tell it to detach other sessions. You can also create a grouped session with “tmux new -t othersession” if you want them to have different a current window.

All of the stuff at that link is possible in tmux and is often much easier…

[Sep 15, 2009] The Many Uses of Screen By Juliet Kemp

September 11, 2009 | ServerWatch.com

Monitor a window for output: Hit Ctrl-A Shift-M when in window 1, and then flip to window 2 (with Ctrl-A N), and you'll be notified in window 2 when there's output in window 1. This is useful if you're running a job that takes a long time; no need to keep flipping between windows. You can also monitor for silence with Ctrl-A _. This is useful if you're running a compile job or something else that outputs a lot of stuff when it's running successfully.

Selected comments

By berto September 15 2009 2:26 PMPDT

the one i use ;)

@bertocasa (amelgar) ~ :: cat .screenrc
#kill startup message
startup_message off

defscrollback 1024
hardstatus on
hardstatus alwayslastline

#hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}% w %=%{..G} %H %{..Y} %m/%d %C%a "

hardstatus string '%{= kg}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?% Lw%?%?%= %{g}]%{=b C}[ %d %M %c ]%{W}'

screen -t rOOt 0 su -
screen -t ncmpc 1 bash
screen -t terminal 2 bash
screen -t MComander 3 mc
screen -t vimTerm 4 bash
screen -t terminal 5 bash
screen -t dropbox 6 bash

[Sep 15, 2009] Cut and Paste With Screen By Juliet Kemp

September 8, 2009 | ServerWatch.com

To enter copy mode in screen, hit Ctrl+A, then [. You can now use the arrow keys, or vim-like keybindings, to move around the screen. 0 gets you to the start of a line, and $ to the end of a line.

  1. When you've reached the point where you want to start the copy, hit Enter.
  2. Move the cursor to the end point of your selection (you'll see what you're copying highlighted), and then hit Enter again.
  3. Now move the cursor to wherever you want to paste the selection (you can move to another screen within your session), and hit Ctrl+A ] to paste the selection.

You can also use Ctrl+A > filename to paste the selection to a filename and Ctrl+A < filename to read a file into the selection buffer so you can then paste it out again using Ctrl+A ].

When in copy mode, you can also use screen's scrollback feature (i.e., you can scroll back upward past the top of the currently displayed text) and the search function.

Use ? to search backward. This is probably what you want initially, as you'll be starting by default from the bottom of the scrollback.

/ searches forward.

Bear in mind that the default scrollback is only 100 lines. To increase this, add a line to your ~/.screenrc:

defscrollback 1000

[Jul 11, 2009] Screen (vim + gnu screen) - Start gnu screen w- your vim session and a split shell + send commands to the sh vim online

created by Eric Van Dewoestine

Screenshot: http://eclim.sourceforge.net/_images/screenshots/vim/gnu_screen_shell.png

Note: gvim is not supported. You must be running vim in a console.

Currently tested on Linux and cygwin, but should work on any unix based
platform where screen is supported (OSX, BSD, Solaris, etc.). Note that
in my testing of cygwin, invocations of screen were significantly slower
and less fluid than on Linux.

This plugin aims to simulate an embedded shell in vim by allowing you to
easily convert your current vim session into one running in gnu screen
with a split gnu screen window containing a shell, and to quickly send
statements/code to whatever program is running in that shell (bash,
python, irb, etc.).

Commands:
:ScreenShell [cmd] - Opens the split shell by doing the following:
1. save a session file from your currently running vim instance
(current tab only)
2. start gnu screen with vim running in it
3. load your saved session file
4. create a lower gnu screen split window and start a shell
5. if a command was supplied to :ScreenShell, run it
Ex. :ScreenShell ipython

Note: If you are already in a gnu screen session, then only steps
4 and 5 above will be run.

:ScreenSend - Send the visual selection or the entire buffer contents to
the running gnu screen shell window.

:ScreenQuit - Save all currently modified vim buffers and quit gnu
screen, returning you to your previous vim instance
running outside of gnu screen
Note: :ScreenQuit is not available if you where already in a gnu
screen session when you ran :ScreenShell.
Note: By default, if the gnu screen session was started by
:ScreenShell, then exiting vim will quit the gnu screen session
as well (configurable via g:ScreenShellQuitOnVimExit).

An example workflow may be:
Open a python file to work on:
$ vim something.py

Decide you want to run all or pieces of the code in an interactive
python shell:
:ScreenShell python

Send code from a vim buffer to the shell:
:ScreenSend

Quit the screen session and return to your original vim session:
:ScreenQuit
or
:qa

Gotchas:
- While running vim in gnu screen, if you detach the session instead of
quitting, then when returning to the non-screen vim, vim will complain
about swap files already existing. So try to avoid detaching.
- Not all vim plugins support saving state to or loading from vim
session files, so when running :ScreenShell some buffers may not load
correctly if they are backed by such a plugin.

install details

Download the script and put it in your plugin directory (~/.vim/plugin).

[Jul 8, 2009] Useful Tricks With Screen

screen is a very useful program which in effect gives you multiple console screens in the same window. It's handy if you're using a console rather than an xterm, or if you're connected to another machine, as it means you can do multiple things u're working remotely: If your connection falls over while you're still in a screen session, you can ssh back to the machine and reattach the screen (with screen -r) and get straight back to where you were, rather than having to start over.

You can also manually detach the screen, with screen -d (detach screen), or by hitting Ctrl-A then D while in a screen session. This leaves the screen running in the background, and it can be useful for running background jobs. Or you can leave a screen session connected to another machine: Run screen before you open the ssh session, then instead of logging out when you're done, detach the screen, and then just reattach it (screen -r) when you need to connect to that machine again. The downside of this is that it does have security implications!

Recent Tips
» xclip: Command-Line Clipboard
» Make It Snappy With Vim
» Unicode Characters in Vim

Read All Tips of the Trade

A final screen trick enables you to remotely look over a user's shoulder if you're trying to fix a problem.

xclip /path/to/file
Log on to the user's machine as him, then type
screen -S debug
Then, get him to type
screen -x debug
and he'll join your screen session. After this, whatever he does will be replicated on your screen (and vice versa). ('debug' is the identifier; any other name would also be fine.) This can save a lot of time when trying to track down a problem or to explain a solution!

[Jul 7, 2009] tmux 0.9

tmux is a "terminal multiplexer". It allows a number of terminals (or windows) to be accessed and controlled from a single terminal. It is intended to be a simple, modern, BSD-licensed alternative to programs... such as GNU screen

Red Hat Magazine A guide to GNU Screen

Customizing the configuration file

Screen keeps its configuration file in the same vein that many applications do: in a dot file in your user’s home directory. This file is aptly named .screenrc. In my experience, most people use ~/.screenrc to do two things:

The lines below are numbered for reference. Your config file should not have numbered lines.

1 hardstatus alwayslastline
2 hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
3
4 # Default screens
5 screen -t shell1	0
6 screen -t shell2	1
7 screen -t server	2	ssh me@myserver

On lines 1 and 2, you are setting the hardstatus. Line 1 makes the hardstatus always show up as the last line. Line 2 is about what will be shown in the hardstatus line. In this case you will see something like so at the bottom:

[June 1, 2009] Screen – Manages multiple sessions on one terminal Ubuntu Geek

Using Screen

From your ssh login prompt enter the following command

screen

or

screen -S 1

and select your profile option.

-S sessionname – When creating a new session, this option can be used to specify a meaningful name for the session. This name identifies the session for “screen -list” and “screen -r” actions.

... ... ...

Customise Screen-profiles

If you look in the bottom right corner you’ll see there’s an “F9 Menu” you can press F9 to reconfigure your screen profiles. Once it opens you should see similar to the following screen here you can see list of changes you can do

Sample screenshots for screen-profile options

[Feb 12, 2004] Curiosity is bliss Essential utility screen

Screen is a command line utility that comes with lots of Unix variants (including Linux). It is a bit hard to describe and to discover. It provides two main features: multiplexing a terminal and detaching/re-attaching sessions.

I originally got shown this by my "System programming" TA, when I asked him if I could disconnect X11 application from one terminal and have them re-open (in the same state) onto another terminal. It turns out this is possible for X11 applications (see xmove or xmx, proxy-based redirections, or guiEvict <via sweetcode>, described in this paper). But "screen" although limited to text applications is so useful that I dropped my search for its X11 equivalent.

Multiplexing: If you start a remote shell (say SSH) but want to do more than one thing at a time, you may want to open more sessions, but you can also use screen. It allows you to switch between multiple shells on the same connection.
You need to first run "screen", then use "Ctrl-A Ctrl-C" (control A, control C) to create a new shell, and you now can switch between shells with "Ctrl-A Ctrl-*" where * is the number for you shell (for ex, use "Ctrl-A Ctrl-1" to switch to shell 1).

Session migration: Let's say you need to disconnect from that session, but you want to continue it from another computer. You can use "Ctrl-A Ctrl-D" to detach screen. All the shells will be maintained, and you can reconnect to the remote machine again and type "screen -R" to re-attach to the original session. This is also very useful in can the connection is lost by accident.

macosxhints.com - Use 'screen' as a serial terminal emulator

I often have to do router configuration via a console port, so I use a Keyspan Serial Adapter to get access. Two problems then present themselves:
  1. ZTerm is a horrible Mac OS X app. It hasn't been updated in five years or so, and isn't a Universal Binary. The developer doesn't seem in any hurry to rectify the situation. It is not worth the shareware fee in its current form.
  2. Minicom requires installation of Fink or MacPorts and is overly complex.
Solution: Use screen, Terminal, and a little AppleScripting.

First, launch Script Editor and type/paste in the following code:

tell application "Terminal"
  do script with command "screen /dev/tty.KeySerial1"
  set number of rows of window 1 to 100
  set number of columns of window 1 to 80
  set background color of window 1 to "black"
  set normal text color of window 1 to "green"
  set custom title of window 1 to "SerialOut"
end tell
Compile and save as an app from within Script Editor, and you have a double-clickable application to launch a serial Terminal session. You may want to customize this slightly -- you can change the screen colors or number of columns or rows. You may also need to customize the screen command with a different device name if you are using something other than the Keyspan Serial Adapter (do an ls tty* of the /dev/ directory to get the right name).

screen uses Control-A to take commands directed to it. So type Control-A followed by Control-\ to exit your screen session. If you fail to do this and exit a Terminal session, you'll leave the screen session alive and the serial resource unavailable until you kill the screen session manually. man screen will show you further commands to send to a screen session.

If anyone can reply with a link to a tutorial on how to wrap an interactive Unix App in Cocoa, that would be the next step -- it would be nice to do this without involving Terminal. If you prefer to use Minicom, you could still use the AppleScript to wrap it into a nice launchable app -- use this older hint to find the right command line commands.

Continued...

Recommended Links

Softpanorama Top Visited

Softpanorama Recommended

Solaris Packages

Solaris Package Archive -- GNU screen 3.9.4

GNU screen 3.9.4 provides you with an ANSI/vt100 terminal emulator, which can multiplex up to 10 pseudo-terminals. On startup, it executes $SHELL in window 0. Then it reads $HOME/.screenrc to learn configuration, keybindings, and possibly open more windows. GNU screen has the ability to detach from your virtual screens and re-attach at a later time.

Email To
Send bug reports or queries to screen@uni-erlangen.de.

Upgrading Packages
When upgrading from an earlier GNU screen package, remember to pkgrm GNUscreen before you pkgadd the new version.

Solaris Issues
Click here to read about 32 bit and 64 bit packages.

Source Code
You can ftp the source code from ftp://ftp.gnu.org/pub/gnu/screen/screen-3.9.4.tar.gz

Special Issues
You may need to configure your terminal definitiosn to get the most out of GNU screen. See the files in the /usr/local/share/screen directory for more information.

See the main packages README for installation information.

User Manual

Screen User's Manual - Table of Contents

Reference

Manpage

[GNU screen manpage]

[Stolen pretty much verbatim from the man page. <PMG>]

Each window in a screen session emulates a VT100 terminal, with some extra functions added. The VT100 emulator is hardcoded; no other terminal types can be emulated.

Usually screen tries to emulate as much of the VT100/ANSI standard as possible. But if your terminal lacks certain capabilities, the emulation may not be complete. In these cases screen has to tell the applications that some of the features are missing. This is no problem on machines using termcap, because screen can use the $TERMCAP variable to customize the standard screen termcap.

But if you do a rlogin on another machine or your machine supports only terminfo this method fails. Because of this, screen offers a way to deal with these cases. Here is how it works:

When screen tries to figure out a terminal name for itself, it first looks for an entry named “screen.<term>”, where <term> is the contents of your $TERM variable. If no such entry exists, screen tries “screen” (or “screen-w” if the terminal is wide (132 cols or more)). If even this entry cannot be found, “vt100” is used as a substitute.

The idea is that if you have a terminal which doesn’t support an important feature (e.g. delete char or clear to EOS) you can build a new termcap/terminfo entry for screen (named “screen.<dumbterm>”) in which this capability has been disabled. If this entry is installed on your machines you are able to do a rlogin and still keep the correct termcap/terminfo entry. The terminal name is put in the $TERM variable of all new windows. Screen also sets the $TERMCAP variable reflecting the capabilities of the virtual terminal emulated. Notice that, however, on machines using the terminfo database this variable has no effect. Furthermore, the variable $WINDOW is set to the window number of each window.

The actual set of capabilities supported by the virtual terminal depends on the capabilities supported by the physical terminal. If, for instance, the physical terminal does not support underscore mode, screen does not put the us and ue capabilities into the window’s $TERMCAP variable, accordingly. However, a minimum number of capabilities must be supported by a terminal in order to run screen; namely scrolling, clear screen, and direct cursor addressing (in addition, screen does not run on hardcopy terminals or on terminals that overstrike).

Also, you can customize the $TERMCAP value used by screen by using the “termcap” .screenrc command, or by defining the variable $SCREENCAP prior to startup. When the is latter defined, its value will be copied verbatim into each window’s $TERMCAP variable. This can either be the full terminal definition, or a filename where the terminal “screen” (and/or “screen-w”) is defined.

Note that screen honors the “terminfo” .screenrc command if the system uses the terminfo database rather than termcap.

When the boolean ‘G0’ capability is present in the termcap entry for the terminal on which screen has been called, the terminal emulation of screen supports multiple character sets. This allows an application to make use of, for instance, the VT100 graphics character set or national character sets. The following control functions from ISO 2022 are supported: lock shift G0 (SI), lock shift G1 (SO), lock shift G2, lock shift G3, single shift G2, and single shift G3. When a virtual terminal is created or reset, the ASCII character set is designated as G0 through G3. When the G0 capability is present, screen evaluates the capabilities S0, E0, and C0 if present. S0 is the sequence the terminal uses to enable and start the graphics character set rather than SI. E0 is the corresponding replacement for SO. C0 gives a character by character translation string that is used during semi-graphics mode. This string is built like the acsc terminfo capability.

When the po and pf capabilities are present in the terminal’s termcap entry, applications running in a screen window can send output to the printer port of the terminal. This allows a user to have an application in one window sending output to a printer connected to the terminal, while all other windows are still active (the printer port is enabled and disabled again for each chunk of output). As a side-effect, programs running in different windows can send output to the printer simultaneously. Data sent to the printer is not displayed in the window. The info command displays a line starting ‘PRIN’ while the printer is active.

Screen maintains a hardstatus line for every window. If a window gets selected, the display’s hardstatus will be updated to match the window’s hardstatus line. If the display has no hardstatus the line will be displayed as a standard screen message. The hardstatus line can be changed with the ANSI Application Program Command (APC): ESC_<string>ESC\. As a convenience for xterm users the sequence ESC]0..2;<string>^G is also accepted.

Some capabilities are only put into the $TERMCAP variable of the virtual terminal if they can be efficiently implemented by the physical terminal. For instance, dl (delete line) is only put into the $TERMCAP variable if the terminal supports either delete line itself or scrolling regions. Note that this may provoke confusion, when the session is reattached on a different terminal, as the value of $TERMCAP cannot be modified by parent processes.

The “alternate screen” capability is not enabled by default. Set the altscreen .screenrc command to enable it.

The following is a list of control sequences recognized by screen. “(V)” and “(A)” indicate VT100-specific and ANSI- or ISO-specific functions, respectively.

ESC E Next Line
ESC D Index
ESC M Reverse Index
ESC H Horizontal Tab Set
ESC Z Send VT100 Identification String
ESC 7 (V) Save Cursor and Attributes
ESC 8 (V) Restore Cursor and Attributes
ESC [s (A) Save Cursor and Attributes
ESC [u (A) Restore Cursor and Attributes
ESC c Reset to Initial State
ESC g Visual Bell
ESC Pn p Cursor Visibility (97801)
Pn = 6 Invisible
7 Visible
ESC = (V) Application Keypad Mode
ESC > (V) Numeric Keypad Mode
ESC # 8 (V) Fill Screen with Es
ESC \ (A) String Terminator
ESC ^ (A) Privacy Message String (Message Line)
ESC ! Global Message String (Message Line)
ESC k A.k.a. Definition String
ESC P (A) Device Control String. Outputs a string directly to the host terminal without interpretation.
ESC _ (A) Application Program Command (Hardstatus)
ESC ] 0 ; string ^G (A) Operating System Command (Hardstatus, xterm title hack)
ESC ] 83 ; cmd ^G (A) Execute screen command. This only works if multi-user support is compiled into screen. The pseudo-user “:window:” is used to check the access control list. Use aclchg :window: -rwx #? to create a user with no rights and allow only the needed commands.
Control-N (A) Lock Shift G1(SO)
Control-O (A) Lock Shift G0 (SI)
ESC n (A) Lock Shift G2
ESC o (A) Lock Shift G3
ESC N (A) Single Shift G2
ESC O (A) Single Shift G3
ESC ( Pcs (A) Designate character set as G0
ESC ) Pcs (A) Designate character set as G1
ESC * Pcs (A) Designate character set as G2
ESC + Pcs (A) Designate character set as G3
ESC [ Pn ; Pn H Direct Cursor Addressing
ESC [ Pn ; Pn f same as above
ESC [ Pn J Erase in Display
Pn = None or 0 From Cursor to End of Screen
1 From Beginning of Screen to Cursor
2 Entire Screen
ESC [ Pn K Erase in Line
Pn = None or 0 From Cursor to End of Line
1 From Beginning of Line to Cursor
2 Entire Line
ESC [ Pn X Erase character
ESC [ Pn A Cursor Up
ESC [ Pn B Cursor Down
ESC [ Pn C Cursor Right
ESC [ Pn D Cursor Left
ESC [ Pn E Cursor next line
ESC [ Pn F Cursor previous line
ESC [ Pn G Cursor horizontal position
ESC [ Pn ' same as above
ESC [ Pn d Cursor vertical position
ESC [ Ps ;...; Ps m Select Graphic Rendition
Ps = None or 0 Default Rendition
1 Bold
2 (A) Faint
3 (A) Standout Mode (ANSI: Italicized)
4 Underlined
5 Blinking
7 Negative Image
22 (A) Normal Intensity
23 (A) Standout Mode off (ANSI: Italicized off)
24 (A) Not Underlined
25 (A) Not Blinking
27 (A) Positive Image
30 (A) Foreground Black
31 (A) Foreground Red
32 (A) Foreground Green
33 (A) Foreground Yellow
34 (A) Foreground Blue
35 (A) Foreground Magenta
36 (A) Foreground Cyan
37 (A) Foreground White
39 (A) Foreground Default
40 (A) Background Black
...
49 (A) Background Default
ESC [ Pn g Tab Clear
Pn = None or 0 Clear Tab at Current Position
3 Clear All Tabs
ESC [ Pn ; Pn r (V) Set Scrolling Region
ESC [ Pn I (A) Horizontal Tab
ESC [ Pn Z (A) Backward Tab
ESC [ Pn L (A) Insert Line
ESC [ Pn M (A) Delete Line
ESC [ Pn @ (A) Insert Character
ESC [ Pn P (A) Delete Character
ESC [ Pn S Scroll Scrolling Region Up
ESC [ Pn T Scroll Scrolling Region Down
ESC [ Pn ^ same as above
ESC [ Ps ;...; Ps h Set Mode
ESC [ Ps ;...; Ps l Reset Mode
Ps = 4 (A) Insert Mode
20 (A) Automatic Linefeed Mode
34 Normal Cursor Visibility
?1 (V) Application Cursor Keys
?3 (V) Change Terminal Width to 132 columns
?5 (V) Reverse Video
?6 (V) Origin Mode
?7 (V) Wrap Mode
?9 X10 mouse tracking
?25 (V) Visible Cursor
?47 Alternate Screen (old xterm code)
?1000 (V) VT200 mouse tracking
?1047 Alternate Screen (new xterm code)
?1049 Alternate Screen (new xterm code)
ESC [ 5 i (A) Start relay to printer (ANSI Media Copy)
ESC [ 4 i (A) Stop relay to printer (ANSI Media Copy)
ESC [ 8 ; Ph ; Pw t Resize the window to Ph lines and Pw columns (SunView special)
ESC [ c Send VT100 Identification String
ESC [ x Send Terminal Parameter Report
ESC [ > c Send VT220 Secondary Device Attributes String
ESC [ 6 n Send Cursor Position Report

Command line options

Screen has the following command-line options:

-a
include all capabilities (with some minor exceptions) in each window's termcap, even if screen must redraw parts of the display in order to implement a function.
-A
Adapt the sizes of all windows to the size of the current terminal. By default, screen tries to restore its old window sizes when attaching to resizable terminals (those with "WS" in its description, e.g. suncmd or some xterm).
-c file
override the default configuration file from "$HOME/.screenrc" to file.
-d|-D [pid.tty.host]
does not start screen, but detaches the elsewhere running screen session. It has the same effect as typing "Ctrl-a d" from screen's controlling terminal. -D is the equivalent to the power detach key. If no session can be detached, this option is ignored. In combination with the -r/-R option more powerful effects can be achieved:
-d -r
Reattach a session and if necessary detach it first.
-d -R
Reattach a session and if necessary detach or even create it first.
-d -RR
Reattach a session and if necessary detach or create it. Use the first session if more than one session is available.
-D -r
Reattach a session. If necessary detach and logout remotely first.
-D -R
Attach here and now. In detail this means: If a session is running, then reattach. If necessary detach and logout remotely first. If it was not running create it and notify the user. This is the author's favorite.
-D -RR
Attach here and now. Whatever that means, just do it.
Note: It is always a good idea to check the status of your sessions by means of "screen -list".
-e xy
specifies the command character to be x and the character generating a literal command character to y (when typed after the command character). The default is "Ctrl-a" and `a', which can be specified as "-e^Aa". When creating a screen session, this option sets the default command character. In a multiuser session all users added will start off with this command character. But when attaching to an already running session, this option changes only the command character of the attaching user. This option is equivalent to either the commands "defescape" or "escape" respectively.
-f, -fn, and -fa
turns flow-control on, off, or "automatic switching mode". This can also be defined through the "defflow" .screenrc command.
-h num
Specifies the history scrollback buffer to be num lines high.
-i
will cause the interrupt key (usually Ctrl-c) to interrupt the display immediately when flow-control is on. See the "defflow" .screenrc command for details. The use of this option is discouraged.
-l and -ln
turns login mode on or off (for /etc/utmp updating). This can also be defined through the "deflogin" .screenrc command.
-ls and -list
does not start screen, but prints a list of pid.tty.host strings identifying your screen sessions. Sessions marked `detached' can be resumed with "screen -r". Those marked `attached' are running and have a controlling terminal. If the session runs in multiuser mode, it is marked `multi'. Sessions marked as `unreachable' either live on a different host or are `dead'. An unreachable session is considered dead, when its name matches either the name of the local host, or the specified parameter, if any. See the -r flag for a description how to construct matches. Sessions marked as `dead' should be thoroughly checked and removed. Ask your system administrator if you are not sure. Remove sessions with the -wipe option.
-L
tells screen your auto-margin terminal has a writable last-position on the screen. This can also be set in your .screenrc by specifying `LP' in a "termcap" command.
-m
causes screen to ignore the $STY environment variable. With "screen -m" creation of a new session is enforced, regardless whether screen is called from within another screen session or not. This flag has a special meaning in connection with the `-d' option:
-d -m
Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.
-D -m
This also starts screen in "detached" mode, but doesn't fork a new process. The command exits if the session terminates.
-O
selects a more optimal output mode for your terminal rather than true VT100 emulation (only affects auto-margin terminals without `LP'). This can also be set in your .screenrc by specifying `OP' in a "termcap" command.
-q
Suppress printing of error messages. In combination with "-ls" the exit value is as follows: 9 indicates a directory without sessions. 10 indicates a directory with running but not attachable sessions. 11 (or more) indicates 1 (or more) usable sessions. In combination with "-r" the exit value is as follows: 10 indicates that there is no session to resume. 12 (or more) indicates that there are 2 (or more) sessions to resume and you should specify which one to choose. In all other cases "-q" has no effect.
-r [pid.tty.host]
-r sessionowner/[pid.tty.host]
resumes a detached screen session. No other options (except combinations with -d/-D) may be specified, though an optional prefix of [pid.]tty.host may be needed to distinguish between multiple detached screen sessions. The second form is used to connect to another user's screen session which runs in multiuser mode. This indicates that screen should look for sessions in another user's directory. This requires setuid-root.
-R
attempts to resume the first detached screen session it finds. If successful, all other command-line options are ignored. If no detached session exists, starts a new session using the specified options, just as if -R had not been specified. The option is set by default if screen is run as a login-shell (actually screen uses "-xRR" in that case). For combinations with the -d/-D option see there.
-s
sets the default shell to the program specified, instead of the value in the environment variable $SHELL (or "/bin/sh" if not defined). This can also be defined through the "shell" .screenrc command.
-S sessionname
When creating a new session, this option can be used to specify a meaningful name for the session. This name identifies the session for "screen -list" and "screen -r" actions. It substitutes the default [tty.host] suffix.
-t name
sets the title (a.k.a.) for the default shell or specified program. See also the "shelltitle" .screenrc command.
-U
Run screen in UTF-8 mode. This option tells screen that your terminal sends and understands UTF-8 encoded characters. It also sets the default encoding for new windows to `utf8'.
-v
Print version number.
-wipe [match]
does the same as "screen -ls", but removes destroyed sessions instead of marking them as `dead'. An unreachable session is considered dead, when its name matches either the name of the local host, or the explicitly given parameter, if any. See the -r flag for a description how to construct matches.
-x
Attach to a not detached screen session. (Multi display mode).
-X
Send the specified command to a running screen session. You can use the -d or -r option to tell screen to look only for attached or detached screen sessions. Note that this command doesn't work if the session is password protected.

Random Findings

xmx: A Screen-ish program for X (2.75 / 4) (#95)
by froindlaven on Wed Mar 10, 2004 at 11:21:28 PM EST

Here's a cool X program which is both an X client and server. You can attach/detach to it much like screen. I tried it out when I had to jump around from lab machine to lab machine and it worked pretty well. In the end, I opted for just using ssh and screen.

dtach - A program that emulates the detach feature of screen

dtach is a tiny program that emulates the detach feature of screen, allowing you to run a program in an environment that is protected from the controlling terminal and attach to it later. dtach does not keep track of the contents of the screen, and thus works best with programs that know how to redraw themselves.

dtach does not, however, have the other features of screen, such as its support of multiple terminals or its terminal emulation support. This makes dtach extremely tiny compared to screen, making it more easily audited for bugs and security holes, and also allows it to fit in environments where space is limited, such as on rescue disks.

dtach has many possible uses, even though it is tiny. With dtach, you can:


The latest version of dtach is version 0.7, which you can fetch here. Other download formats may be available at the sourceforge download area for dtach.

The changes in version 0.7 are:

The changes in version 0.6 are: The changes in version 0.5 are: The changes in version 0.4 are: The changes in version 0.3 are: You can also obtain information on how to access the CVS tree here, and access the sourceforge project page here.

You can send any comments or questions about dtach to the author. Comments and suggestions are welcome.




Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least


Copyright © 1996-2014 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine. This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting hosting of this site with different providers to distribute and speed up access. Currently there are two functional mirrors: softpanorama.info (the fastest) and softpanorama.net.

Disclaimer:

The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: May 26, 2014