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 name | TRUE if named alias exists. |
| -d path | TRUE if the path specified is a directory. |
| -e path | TRUE if the path specified exists. |
| -f path | TRUE if the path specified is a plain file. |
| -x path | TRUE if the path specified is an executable file. |
| -z path | TRUE if the path is greater than 0 characters long. |
| String Tests | | |
| val1 = val2 | TRUE if val1 and val2 are equal. |
| val1 == val2 | TRUE if val1 and val2 are equal. |
| val1 != val2 | TRUE if val1 and val2 not equal. |
| val1 -eq val2 | TRUE if val1 and val2 are equal, numerically |
| val1 -ne val2 | TRUE 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.