[clug] Terminal Control Sequences

steve jenkin sjenkin at canb.auug.org.au
Sat Jul 3 20:31:13 MDT 2010


Francis Whittle wrote on 4/07/10 11:03 AM:
> You might find http://rtfm.etla.org/xterm/ctlseq.html to be of
> interest.  It's a fairly comprehensive list of control sequences
> available to xterm, which also applies to gnome terminal.

Terminal control strings come from a time when serial-terminals were
expensive, 'leading edge' and proprietary.
Vendors devised their own systems that were incompatible
(purposefully?). Some of the first malware remapped function keys or
caused the terminal to send unintended strings.

Unix/BSD, being the Universal Glue/Solvent, was the first to arrive with
a portable abstraction to allow any terminals to be used.
Hence the TERM variable in your shell environment.
They did Time Zones and Internationalisation early as well.
[The LC & LANG variables are for the ANSI standard libs.]

The 'xterm' is based on the DEC vt100. There's an 'ansi' terminal as
well. Sorta, kinda vt100, IIRC.

The underlying mechanism is 'terminfo', 'ncurses' & friends (started as
termcap/curses by Bill Joy. He wrote 'vi' first doing direct cursor
addressing, then created the 'curses library', but didn't rewrite 'vi'
with it...)

The Terminfo database is compiled (with 'tic') and stored in
/usr/share/terminfo.
['man terminfo' explains the names it uses for different functions]

'infocmp' (or 'untic') will display your current mappings.

'tput' will output a named control-sequence.
'tput reset' and 'tput clear' are useful to know.


The 'xterm' is special because it can be manipulated both by terminal
control sequences and by X-11.
You have at least two ways to set the title string.

The man-page on 'xterm' has the full glory (or gory details) of what's
possible... 'man -s 7 X' gives some more of the story and the names of
its management commands. [Your Window Manager (gnome/KDE/twm/...) has
more functions & cmds again.]

If you want to set icon text, change foreground/background colours and
many other things, 'xrdb' (X server resource database utility) can be
used to set 'resources' for xterms and other programs... Even screen
position.
[Some resources are common with terminal control sequences, different
naming scheme.]

BE WARNED: 'xrdb', like 'rm' is most powerful and *most* dangerous.

You probably always want to use 'xrdb -merge <file>', otherwise you'll
zap your entire resources DB... Not a good look.

'xrdb -query' is your friend and a good place to start.

You can start a new xterm with an initial command and a some other
settings. I used to find this a good way to create a consistent
environment when managing a bunch of remote Unixes... Set colours,
titles, size, position and then ssh into box...

Others will know a whole lot more and a bunch of other Really Useful
Tricks...

Hope this is useful in some way.

s

-- 
Steve Jenkin, Info Tech, Systems and Design Specialist.
0412 786 915 (+61 412 786 915)
PO Box 48, Kippax ACT 2615, AUSTRALIA

sjenkin at canb.auug.org.au http://members.tip.net.au/~sjenkin


More information about the linux mailing list