tscreen


GNU Screen

Recent GNU Screen Features

tscreen is a fork of GNU Screen, created by copying a very recent snapshot of the GNU Screen development tree. This means there might be facilities present which are new to you for which I deserve no credit.

If you're used to an older version of GNU Screen these facilities might be new to you:

bindkey

bindkey allows you to create simple macros. The following is a good example:

bindkey "\024" mapdefault
bindkey me stuff 'Steve Kemp'

Now if you have a window open and you type "me" into your shell it'll be replaced with "Steve Kemp". If you want the literal word "me" to be inserted press Ctrl-t first.

You can view bindings with bindkey, or read more via "info tscreen".

Vertical Split

In addition to the horizontal split (Ctrl-a S) you may also split vertically via (Ctrl-a |).

Layouts

One common complaint in the past has been that if you split your window and detach the session when you restore the layout is gone.

This may be prevented via the new layout command. Simply add the following to your ~/.tscreenrc:

layout new default

This will ensure that you have a lyaout which is saved by default.

top
My additions & changes

These are currently the most obvious changes which have been made to the GNU Screen sources:

Renamed Binary & Configuration files

Although it is still a work in progress all the obvious mentions of "screen" have been replaced with "tscreen".

This includes the configuration file(s) read at startup which are now:

  • /etc/tscreenrc.
  • ~/.tscreenrc.

Configuration Files May Be Executables

The handling of the source primitive has been updated to allow a trailing "|" character - this suggests the file will not be read, but instead will be executed.

This is an example usage taken from my ~/.tscreenrc file:

#
#  Load the dynamic configuration file if it exists and is
# executable.
#
#  The output of executing ~/.tscreen.dynamic will be parsed.
#
if -x ~/.tscreen.dynamic  'source ~/.tscreen.dynamic|'

This allows you to make the configuration extremely user, machine, or mood specific. This allows more configuration freedom than the use of the if primitive described below.

New if primitive

The if primitive allows you to write conditional configuration files.

The format of if is one of:

if [test] [arg]       "string 1" "string 2" .. "string N"
if [arg1] [op] [arg2] "string 1" "string 2" .. "string N"

If the test succeeds each of the named strings will be executed via eval. The available tests are:

Single Arg Tests
-a nameTRUE if named alias exists.
-d pathTRUE if the path specified is a directory.
-e pathTRUE if the path specified exists.
-f pathTRUE if the path specified is a plain file.
-x pathTRUE if the path specified is an executable file.
-z pathTRUE if the path is greater than 0 characters long.
String Tests
val1 = val2TRUE if val1 and val2 are equal.
val1 == val2TRUE if val1 and val2 are equal.
val1 != val2TRUE if val1 and val2 not equal.
val1 -eq val2TRUE if val1 and val2 are equal, numerically
val1 -ne val2TRUE if val1 and val2 are not equal, numerically
Single Arg Tests

Each test may be inverted via a ! prefix, such as "if !-x ..", or "if !-a ..". The specified path will be tilde-expanded.

Double Arg Tests

Environmental variables will be expanded, if specified.

If either argument begins and ends with backticks (`) the argument will be replaced with the output of that command - with newlines stripped removed.

Here's a pair of examples that demonstrate both tests forms:

#  If we have cmatrix then:
#   If we're idle for more than 60 seconds :
#    - find/create the window titled 'cmatrix'
#    - run cmatrix in it.
#
if -x /usr/bin/cmatrix 'idle 60 eval "screen -F -t cmatrix /usr/bin/cmatrix -f -o -u 10"'
#
#  If the current username is 'skx' then we'll do something
#
if $USER = skx "source ~/.tscreen.skx"
#
#  If hostname is gold.my.flat do something ..
#
if `hostname` = "gold.my.flat" "alias gold screen ssh skx@localhost"
Improved source primitive

The source command may be used in your configuration file(s) to include another file.

The source command has been improved to allow reading a directory. The following example will make that clear:

#
#  Include each file in the named directory, ignoring dotfiles, and files
# ending in ~
#
source ~/.tscreenrc.d/
Sexy new alias primitive

This allows you to write aliases for existing commands. The following example makes this clear:

# make "shout" a synonym for "echo"
alias shout echo
# use it
shout "Alert!"
# unset it
alias shout
# error:
shout "this will fail"

The alias primitive also allows you to bind arguments, and essentially run mini-functions. For example:

#
#  Caption toggle
#
alias caption_off  eval "caption splitonly"
alias caption_on   eval "caption always"
#
#  Status toggle
#
alias status_off   eval "hardstatus ignore"
alias status_on    eval "hardstatus alwayslastline"
#
#  Disable both caption and status, and show a message.
#
alias fullscreen   eval "status_off" "caption_off" "echo 'fullscreen'"
alias captioned    eval "status_on"  "caption_on"  "echo 'captioned' "
#
#  Bind these functions to keys
#
bind f fullscreen
bind F captioned
#
#  Clear the scrollback history, and the current screen
#
alias clearscrollback eval "scrollback 0" "clear" "scrollback 15000" "echo cleared"

You may have an unlimited number of aliases defined.

New unaliasall primitive

This primitive is similar in purpose to the unbindall primitive I've added - in short it removes all currently defined aliases.

New aliaslist primitive

To view the aliases you've got defined you may use the aliaslist command.

New hide primitive

The hide primitive allows you to define a window as being hidden - the next/prev/other window operations won't switch to it.

(You might instead prefer to use the "window groups" feature to get this same effect.)

New unbindall primitive

The new unbindall primitive unsets all current bindings, nicely neutering tscreen.

tilde expansion

The logfile and chdir primitives have been updated to use expand "~" appropriately.

Improved screen primitive
The screen command now accepts an "-F" argument, which means "find existing window".

This allows you to define an alias like this:

# find the window called mutt, and switch to it.  If not found create it.
alias mutt screen -F -t mutt mutt
Improved lastmsg primitive

The lastmsg primitive now shows you the most recent 20 messages produced in the status area, rather than the last one.

top