http://invisible-island.net/xterm/
Copyright © 1997-2021,2022 by Thomas E. Dickey
Here is the latest version of this file.
From the manual page:
The xterm program is a terminal emulator for the X Window System. It provides DEC VT102/VT220 and selected features from higher-level terminals such as VT320/VT420/VT520 (VTxxx). It also provides Tektronix 4014 emulation for programs that cannot use the window system directly. If the underlying operating system supports terminal resizing capabilities (for example, the SIGWINCH signal in systems derived from 4.3bsd), xterm will use the facilities to notify programs running in the window whenever it is resized.
That is, xterm (pronounced "eks-term") is a specific program, not a generic item. It is the standard X terminal emulator program.
This FAQ presents various useful bits of information for both the specific program as well as other programs that imitate it.
As a stylistic convention, the capitalized form is "XTerm", which corresponds to the X resource class name. Similarly, uxterm becomes "UXTerm".
I've been working on xterm since early 1996 (see my changelog for details).
But the program is much older than that:
A lot of people, cited at the bottom of the manual page wrote the original xterm program, maintained by the X Consortium (later part of The Open Group – I'm well aware of the distinction, but am citing when the work was done, not who the current owner may be). There is no changelog, and it is not clear who did what. Email from Jim Gettys (September 1998) provides some background:
Cast of thousands...
To give a bit of history, xterm predates X!
It was originally written as a stand-alone terminal emulator for the VS100 by Mark Vandevoorde, as my coop student the summer that X started.
Part way through the summer, it became clear that X was more useful than trying to do a stand alone program, so I had him retarget it to X. Part of why xterm's internals are so horrifying is that it was originally intended that a single process be able to drive multiple VS100 displays. Don't hold this against Mark; it isn't his fault.
I then did a lot of hacking on it, and merged several improved versions from others back in.
Notable improvements include the proper ANSI parser, that Bob McNamara did.
The Tek 4010 support came from a guy at Smithsonian Astrophysical Observatory whose name slips my mind at the moment.
Ported to X11 by Loretta Guarino.
Then hacked on at the X Consortium by uncounted people.
Email from Doug Mink (October 1999) provides more background:
I was checking out the newly revised AltaVista search engine to see what was on the net about xterm, and I found your pages. I can add to the FAQ in that I was the "guy at the Smithsonian Astrophysical Observatory" Jim Gettys refers to. I am listed at the end of the man page under authors. What happened was that I was hired by SAO (after leaving the research staff at MIT) in October 1985 to write analysis software for the Spacelab 2 Infrared Telescope which was to fly on the Space Shuttle in 1985 less than six months after I was hired. I came with a tar tape full of software I had written for Unix and Tektronix terminals, but I was presented with a VS100 terminal which had an early version (X6 or so) of xterm, with no graphics capabilities. SAO is at Harvard, across Cambridge from MIT, where Jim Gettys was detailed from DEC to the X project, and Jim had connections with SAO, having worked here after college (MIT, where we had both worked at the observatory at various times); he was still sharing an apartment with an SAO colleague of mine, too. Anyway, everyone decided that since I knew Tektronix commands pretty well, and our group desparately needed the graphics capabilities, it would be a good use of my time to implement a Tektronix terminal emulator under X. So I set to work learning more C--I had only written a couple of wrappers to C I/O routines so I could use them with my Fortran software--and wrote a Tektronix emulator. The only X documentation at the time was the code itself. While I was at it, I wrote an improved Tektronix emulator for our Imagen laser printer which used the full resolution of that 300 dpi printer instead of the effective 100 dpi (i.e. jaggy) emultator distributed with the printer. The original xterm Tek emulator shared a window with the VT100 emulator, much like on the VT240 terminals which I had been using at MIT before I came to Harvard. With a VAX 750 running several VS100's, window creation was sloowww, so sharing a window was the quickest way to do things, and all of my software was written for that mode of operation, anyway. While I wrote the emulator so that my software would work on it, it was tested by the X group against a BBN graphics package, the name of which slips my mind right now.
Anyway, 15 years later, I am still using xterm and some of the same mapping software I wrote the emulator for. And I am still at the Smithsonian Astrophysical Observatory.
VS100 refers to the VAXstation 100, introduced by DEC in 1984 (see manual).
There is a git repository here which gives some more of xterm's prehistory. But it has no usable data for X10 (see initial revisions in 1985/1986). The X developers did not really start checking in their code until 1987.
The earliest version of xterm which is available is from X10R3. According to the xc-historical repository, that was February 1, 1986 (a change to the rgb.c file). Even that date is suspect because the X10R3 tarball contains xterm files later than that date:
17024 May 17 1986 xterm/util.c
31545 May 17 1986 xterm/main.c
1377 Feb 10 1986 xterm/Makefile
10804 Feb 3 1986 man/xterm.1
660 Feb 2 1986 xterm/terminfo
606 Feb 2 1986 xterm/termcap
1178 Feb 2 1986 xterm/tabs.c
10525 Feb 2 1986 xterm/screen.c
2907 Feb 2 1986 xterm/resize.c
6699 Feb 2 1986 xterm/ptyx.h
2720 Feb 2 1986 xterm/input.c
2959 Feb 2 1986 xterm/esctable.h
4482 Feb 2 1986 xterm/cursor.c
7661 Feb 2 1986 xterm/chartable.h
23543 Feb 2 1986 xterm/charproc.c
13990 Feb 2 1986 xterm/button.c
1122 Feb 2 1986 xterm/buf.c
3932 Feb 2 1986 xterm/ansi.c
15662 Feb 2 1986 xterm/Tplot.c
2382 Feb 2 1986 xterm/README
234 Feb 2 1986 cursors/xterm_mask.cursor
234 Feb 2 1986 include/X/cursors/xterm_mask.cursor
261 Feb 2 1986 cursors/xterm.cursor
261 Feb 2 1986 include/X/cursors/xterm.cursor
1335 Dec 21 1985 xterm/icon.ic
1350 Dec 21 1985 xterm/icon_mask.ic
But since the X10R3 tarball contains only 10 “later” files out of 974, the 3-4 xterm files are just some after-the-fact correction whose reason is long lost.
A posting by Andreas Motl to nfo.links.computing in March 2003 recapitulates the content of a page Linux desktops (GUIs, widgets, window managers, etc) (Jorn Barger, November 2002). That mentions X10 (e.g., “X v10”):
1985: Sep: X v9 distributed as free [cite] cf Andrew [Gettys] 1985: X/Open Portability Guide [cite] 1985: Oct: Amiga 1.0 [info] 1985: 20Nov: Windows 1.0 ships [tour] 1985: Dec: Clayton Elwell's Portable User Interface Library project [GooJa] 1985: Dec: X v10r2 [annc] "X is a portable network transparent window system for bitmap displays. Applications can be run from any machine in a local area network via stream connections (currently TCP and Unix domain are supported). X is a fully hierarchic window system intended to be very flexible. Manipulation of existing windows is done with an external window manager; if you don't like ours, write your own. Applications include a terminal emulator (~VT102 and Tek 4010), load monitor, clock, imagen previewer, and several window managers among other things." no-date: Windows 2.0 clones Mac interface; withdrawn and tweaked to avoid lawsuit? [cite] 1986: Jan: DEC announces VAXstation with X 1986: Feb: X v10r3 [annc]
September 1985 might be accurate for X version 9. However, the first line of the xterm manual page from X10R3 says
.TH XTERM 1 "1 January 1985" "X Version 10"
Jim Gettys might be able to explain that. Several of the files in that version of xterm have copyright dates from 1984, making that the likely beginning of development for xterm. Other parts of the X10R3 source tree have similar clues. For example, Xlib may have begun development in 1984, but since it was unreleased until the end of 1985, the actual date is indeterminate.
A comment by Jim Fulton on slashdot in 2000 gives more details on the early versions of X:
There weren't really ten full releases prior to X11R1, however there were 10 incompatible revs of the protocol. Most of the early versions were primarily used within MIT (Athena and LCS) and friendly commercial R&D labs. Here's some of the pre-history based on cryptic notes and blurry memory: X1 - summer 1984 - the first version, based on a substantial rearchitecting of the UNIX port of the W Window System (originally developed for the V Kernel). X3 - fall 1984 - used internally at MIT as the initial basis of various plotting packages for coursework. X6 - spring 1985 - first version licensed by MIT to various companies (including Cognition, MASSCOMP, and Digital) for use in commercial products. It cost $100 and if you wanted you could stop off at the (very small) licensing office to pick up your own magtape. X8/X9 - fall 1985 - added color (X8 lasted all of about a week; X9 was quickly released to fix a protocol alignment problem that impacted ports on the IBM PC/RT). Many organizations began developing ports (including a version to the Lexidata 9000 display card for VAXen that was used at the Autofact tradeshow in late 1985 to show a prototype of the first 3rd party application: a mechanical engineering design system). X.V10R1 - spring 1986 - first version released by MIT that did not require signing a license agreement. Also the first version to have a DOS Xserver developed. X.V10R[234] - fall 1986 & spring 1987 - an explosion of ports done on a variety of platforms. X.V11R1 - Sep 15, 1987 - major overall done in collaboration with folks from Digital, Sun, IBM, and other companies. Formed the basis of core protocol used today. Companies and organizations releasing X-based products used this release as a starting port for incorporating into their own distributions. X.V11R2 - March 1, 1988 - first version released under the auspices of the newly-formed MIT X Consortium. The MIT X Consortium continued to put out releases of X11 for a number of years. Then in the mid-90s, it was spun off into a separate not-for-profit organization (simple the X Consortium). As has been noted, that eventually folded into various organizations that became X.ORG. The rest is history. :) Jim Fulton
My involvement with xterm through XFree86 began at the end of 1995. This website has been "here" since 2001/6/5, replacing my ClarkNet page. I started the ClarkNet page 1996/12/31, as a followup to the release of ncurses 4.0) which featured xterm as one of the 16 programs I was involved with. From the outset, the page provided a link to a snapshot of the current source. Copies of patches which I sent to XFree86 were available on the ftp area.
XFree86 had its sources in CVS, but (like others in that era), were not directly visible to random developers. That came later. I started by downloading the sources (30Mb of compressed tar-files on a 56Kb phone connection took about 6 hours) and updating them with patches from the XFree86 mailing list.
Like the other programs that I worked on with others (vile, tin, lynx), I set up an RCS archive to track my changes locally before sending patches to the development list. As the XFree86 developers issued new patches, I would re-synchronize my archive. Later, XFree86 provided CVS (initially readonly). I was granted commit privileges on this in November 2000, and stopped mailing patches after #149.
Throughout this period, my work on xterm was released as part of XFree86. It was rare for a separate package to be provided. That was due to the potential conflict between the install procedures. Users of the downloads from my web/ftp site were predominantly individual developers.
There were exceptions. Christian Weisgerber proposed a package for FreeBSD ports later in 1999 (ports/15545: new port: x11/xterm, followup in March 2000). However, that was an exception. None of the Linux distributions provided a separate package before 2003 (when Mike Harris created a package of patch #177 for Red Hat). Again that is more of an exception than a rule:
Given that context (sources distributed via XFree86 CVS, releases via XFree86), the statement made by an Xorg hacker early in 2005 asserting that “It has not been maintained by anyone within the XFree86 or X.org trees for many years” was at best misleading.
After the “fork” (sic) of Xorg in 2004, I continued to commit changes for xterm in XFree86 CVS until patch #216 in mid-2006. I stopped at that point because it was not possible to incorporate changes into xterm which were not sent to me first. I still send patch announcements to both the XFree86 and Xorg mailing lists, of course.
At that point (mid-2006), the XFree86 CVS was no longer the primary development repository for xterm. My RCS archive filled that need. Later (starting in 2016), I provided Git snapshots using the RCS labels which I make in development:
This FAQ is oriented toward the version of xterm originally distributed with XFree86 (more commonly known as modern, or "new xterm", with a corresponding terminal description "xterm-new"), which was based on the X11R6.3 xterm, with the addition of ANSI color and VT220 controls.
The manual page mentions a VT220. Most terminal emulators documentation talk about VT100. But a VT100 is a rather limited subset of what people expect:
Initially, I was only interested in making colors workable for curses programs.
Later, I noticed that xterm had some support for what would now be termed as ISO-2022. That was a VT220 feature which preceded ISO-2022 called National Replacement Character sets. In any case, it was not a VT100 feature. There were some missing pieces. So I decided to fill in those pieces and make xterm a VT220 emulator. (VT220s do not do ANSI color either—the missing pieces were in other areas).
XTerm also provides features that are in neither VT100 nor VT220, which are used by other programs as "xterm emulation".
By the way, the control string used for setting the titles was not in a standard format:
ESC \.ECMA-48 (the standard) does not describe this particular
control, but prescribes its format (an operating
system command). It does not use a
BEL.
I revised that area starting in 1996,
In addition to implementing the VT220's National
Replacement Character sets (see vttest screenshots), I added other
features to emulate the successive models of DEC terminals. The
decTerminalID
resource (in 1996) lets
users select the emulation to use. Because many of my changes
were extensions (features not in any of DEC's terminals)
and because well-behaved VT100 applications would not use
features from higher-level terminals it was not initially
important to prevent use of those by applications which assumed
they were using just a VT100. Knowledgable users could easily
configure xterm to emulate a VT220. In 2012, I changed the default from
VT100 to VT420.
That was mentioned regarding the title strings. XTerm uses a state machine to handle incoming characters. That is essentially what a real terminal does. Other "xterm" terminal emulators typically do not do this, which makes them not do well with vttest.
You could do that (by changing decTerminalID, but
the results were not that interesting). In retrospect, the VT320
was a stopgap implementation designed to bridge between the VT200
series and the VT420. It provided a standard codepage (for ISO
Latin-1).
While it had other features not found in the VT200-series, most of those are less useful in a terminal emulator. I did adapt the ECMA-48 scrolling operations which the VT320 interpreted as panning the visible display in the terminal's memory. Expect some difference there (if you can find an application on VMS which used the feature).
The VT320 was popular with developers of commercial terminal emulators, whose literature referred to it as supporting ANSI color. It did not do this.
The VT420 was interesting because it provided two features that could be useful:
A VT420, of course, supports all of the features in VT320, in
turn all of the features in VT220, and in turn VT100. Users would
not lose features by changing the default emulation to VT420. By
changing the default emulation, most users would automatically be
able to use applications (such as tmux) that could
perform better if the left/right margin feature is available. I
changed the emulation to VT420 in 2012 for this reason.
XTerm does not emulate some esoteric features (such as dual sessions) because those require hosts using special software, and no publicly-available documentation was available.
Again, the VT500-series is less interesting because most of the features which are not hardware-specific (such as reporting transmission rate) are less useful.
However:
As for the other features, most are not useful in emulation (since they are hardware-specific). Additionally, these less-used features are not documented precisely and since the only point of providing them would be for successful interoperability with legacy applications, some reverse-engineering would be needed to provide a faithful emulation. To date there are no known terminal emulators which do that.
XTerm runs in all of the implementations of X11. As of 2000, I had built and run these since I started working on xterm in 1996:
The older configurations have X11R5 libraries. Only minor changes are needed to make xterm work on those systems. However, X11R6 provided better locale support, as well as new features such as the active icon. X11R7... not much to say there.
Since 2000, there have been many changes (including new platforms such as MacOS, NetBSD, OpenBSD, etc., as well as QNX, Cygwin, and Minix).
The most recent (and well supported) version of xterm is the one that I maintain:
There are several other versions of xterm, based on xterm's source. These include
There are similar programs not based on xterm's source, which are compatible to different degrees. These include
Some of these use the VTE widget. Since that supplies most of the terminal emulation, the remaining differences between programs using VTE tend to be at the level of the window manager (menus, borders, etc.). Other (older) programs which are based on reusable widgets include dtterm and emu.
(I am aware of a few others, such as xcterm, but have not seen a working version of these).
Finally of course, there are a multitude of programs which set TERM to "xterm", in the hope that applications will treat them the same as xterm. For example,
Each of the programs noted here which are well-established and which are known to differ markedly from xterm have their own terminal descriptions in ncurses, to which TERM should be set. Otherwise, bug-reports are misdirected to ncurses which should have been addressed by the respective developers of these programs. These include
Several of these programs are claimed (either by their developers, or their users) to emulate "most" of xterm. To me, "most" would be something quantifiable, e.g., 80 percent. To satisfy my curiousity, I wrote a script to extract the control sequence information from ctlseqs.txt. This counts each control sequence, as well as the variations such as setting bold, color, inverse video. Then I (laboriously) inspected these terminal implementations:
As of mid-November 2010, these were the latest implementations. I included data for the vt220 and vt102 to be able to contrast the various terminal emulators against those as well as xterm. There were:
For each control, there are three possibilities:
The control sequences document lists a few controls which xterm does not (completely) implement, e.g.,
Those are not implemented in xterm because all X applications share the same keyboard (see manpage), and xset is the proper tool for changing auto-repeat. The X10R4 xterm did implement key-repeat, but the feature was removed in X11R1. None of the other terminal emulators implements those either.
| yes | partial | no | program |
|---|---|---|---|
| 488 | 4 | 6 | xterm-new |
| 154 | 6 | 338 | xterm-r6 |
| 188 | 5 | 305 | vt220 |
| 104 | 0 | 394 | vt102 |
| 204 | 3 | 291 | rxvt |
| 219 | 3 | 276 | urxvt |
| 191 | 2 | 305 | putty |
| 170 | 3 | 325 | konsole |
| 184 | 6 | 308 | vte |
Modern xterm implements 188 primary controls. In this table, vte ranks lower than PuTTY because it does not support vt52 emulation. This is not unusual, since the rxvt-based emulators do not, either. However, all vt100's provide this feature; programs lacking this are not really a vt100 emulator. On the other hand, PuTTY (which is not a vt100 emulator due to its incompatible wrapping behavior) supports this feature.
Aside from that, the various emulators implement much the same features from xterm. None implements as many as half of xterm's controls.
| yes | partial | no | program |
|---|---|---|---|
| 488 | 0 | 0 | xterm-new |
| 154 | 6 | 328 | xterm-r6 |
| 182 | 2 | 304 | vt220 |
| 98 | 0 | 390 | vt102 |
| 204 | 3 | 281 | rxvt |
| 219 | 3 | 266 | urxvt |
| 189 | 2 | 297 | putty |
| 170 | 3 | 315 | konsole |
| 184 | 6 | 298 | vte |
DEC VT220 implements 96 primary controls. Modern xterm (as documented), implements most of the VT220. VTE implements fewer than half. The others are a little better. None of the others could be used as a real VT220.
| yes | partial | no | program |
|---|---|---|---|
| 182 | 0 | 6 | xterm-new |
| 78 | 6 | 104 | xterm-r6 |
| 188 | 0 | 0 | vt220 |
| 104 | 0 | 84 | vt102 |
| 101 | 3 | 84 | rxvt |
| 106 | 3 | 79 | urxvt |
| 107 | 2 | 79 | putty |
| 100 | 3 | 85 | konsole |
| 88 | 6 | 94 | vte |
DEC VT102 (the actual flavor used for "vt100" in most cases), implements 68 primary controls. Again, VTE fares worst, and the others a little better.
| yes | partial | no | program |
|---|---|---|---|
| 98 | 0 | 6 | xterm-new |
| 70 | 6 | 28 | xterm-r6 |
| 104 | 0 | 0 | vt220 |
| 104 | 0 | 0 | vt102 |
| 79 | 2 | 23 | rxvt |
| 81 | 2 | 21 | urxvt |
| 86 | 2 | 16 | putty |
| 85 | 3 | 16 | konsole |
| 60 | 1 | 43 | vte |
I have continued to add features to xterm:
The other programs change far more slowly. As a result they implement a smaller fraction of xterm's repertoire in 2019 than in 2010. Even for cases where they implement a function, it may not work properly (see for example the screenshot of VTE in the vttest NRCS examples).
In summary, none of the other terminal emulators emulates "most" of xterm. Instead, they implement the most commonly-used control sequences, and there are differences between them.
Not really problems, but frequently asked questions (the point of this, after all):
XTerm uses fonts given as resource settings. You can switch between these fonts at runtime, using a menu. This is documented in the manpage, in the MENUS section.
X Consortium xterm provides popup menus, by pressing the control key together with the mouse button. Control right mouse button pops up the VT FONTS menu, from which you can select fonts that are specified in xterm's resources. Usually these are in increasing order of size.
Modern xterm provides the menu, plus a feature adapted from rxvt: pressing the shifted keypad plus or minus keys steps through the font menu selections, in order of their size.
XTerm's manpage does not document the syntax for X resources; it is done in the X documentation. If you are instead asking about a problem displaying a given font, it may be due to a problem with your resource settings.
That depends on why you want to print it.
If you want a trace of an interactive session, you should use
the script program. It records every character sent to
the screen, recording them in a file typescript.
There are two drawbacks to this approach:
typescript file.Well, what about logging? Some versions of xterm support logging to a file. In fact modern xterm does. Logging was dropped from X Consortium xterm during X11R5 due to security concerns. Those were addressed, but logging was not reinstated (in fact there is a related bug in xterm). Some people prefer this, because it is convenient: you can start and stop logging a popup menu entry. However
Both script and logging are useful for recording, but they require interpretation to make sense of the trace. You probably would not send that trace to a printer (not twice, anyway).
If you want to print the contents of the screen, modern xterm implements, as part of the VT100 emulation, an "attached" printer.
There are limitations and tradeoffs using the "attached" printer, because it is an emulation:
printAttributes to get more easily printed
output.printerAutoClose resource
to change xterm's behavior to close the printer pipe whenever
the terminal is told to switch the printer offline.If you use the popup menu to print the screen, this will close the printer pipe unless it was already opened by the application running in xterm.
With modern xterm, this is relatively simple. So I'll answer that first.
With X Consortium xterm, you had partial support for DEC VTxxx function keys. Function keys F1 to F12 correspond to DEC's F1 to F12 (sort of). Actually, DEC's VT220 terminals do not have codes for F1 through F5. They are reserved for local functions. And the VT220 (and up) terminals have 20 function keys. So you cannot do anything with the F13 through F20 (i.e., DO, HELP and SELECT). Finally, though xterm is reputed to be VT100-compatible, it has no support for the VT100 keypad (PF1 to PF4, and the "," key).
Modern (XFree86) xterm changed the X Consortium codes for F1
to F4 to match the VT100 PF1 to PF4, except when the emulation
level is VT220 and up. In this case, it generates the same F1 to
F4 codes as X Consortium xterm. Moreover, it adds a new resource
sunKeyboard, which tells the program whether it has
only 12 function keys (i.e., a Sun or PC keyboard). If so (this
is selectable from the popup menu), you can use the control key
with F1 to F12 to get F13 to F24, and use the "+" key on the
keypad as an alias for "," (comma).
The emulation level for modern xterm is set via the resource
decTerminalID, e.g., to 220 for a VT220. Once set,
applications can set the emulation level up or down within that
limit. DEC's terminals are configured in much the same way by a
setup option.
That is the simple way, using a couple of new resources. The traditional way to get function keys involves translations. I have seen a few postings on the newsgroups that do this. Here is one from Bruce Momjian <root@candle.pha.pa.us> for a VT220:
xterm $XTERMFLAGS +rw +sb +ls $@ -tm 'erase ^? intr ^c' \
-name vt220 -title vt220 -tn xterm-220 "$@" &
with the corresponding resources:
XTerm*VT100.translations: #override \n\
<Key>Home: string(0x1b) string("[3~") \n \
<Key>End: string(0x1b) string("[4~") \n
vt220*VT100.translations: #override \n\
~Shift <Key>F1: string(0x1b) string("OP") \n \
~Shift <Key>F2: string(0x1b) string("OQ") \n \
~Shift <Key>F3: string(0x1b) string("OR") \n \
~Shift <Key>F4: string(0x1b) string("OS") \n \
~Shift <Key>F5: string(0x1b) string("[16~") \n \
~Shift <Key>F6: string(0x1b) string("[17~") \n \
~Shift <Key>F7: string(0x1b) string("[18~") \n \
~Shift <Key>F8: string(0x1b) string("[19~") \n \
~Shift <Key>F9: string(0x1b) string("[20~") \n \
~Shift <Key>F10: string(0x1b) string("[21~") \n \
~Shift <Key>F11: string(0x1b) string("[28~") \n \
~Shift <Key>F12: string(0x1b) string("[29~") \n \
Shift <Key>F1: string(0x1b) string("[23~") \n \
Shift <Key>F2: string(0x1b) string("[24~") \n \
Shift <Key>F3: string(0x1b) string("[25~") \n \
Shift <Key>F4: string(0x1b) string("[26~") \n \
Shift <Key>F5: string(0x1b) string("[K~") \n \
Shift <Key>F6: string(0x1b) string("[31~") \n \
Shift <Key>F7: string(0x1b) string("[31~") \n \
Shift <Key>F8: string(0x1b) string("[32~") \n \
Shift <Key>F9: string(0x1b) string("[33~") \n \
Shift <Key>F10: string(0x1b) string("[34~") \n \
Shift <Key>F11: string(0x1b) string("[28~") \n \
Shift <Key>F12: string(0x1b) string("[29~") \n \
<Key>Print: string(0x1b) string("[32~") \n\
<Key>Cancel: string(0x1b) string("[33~") \n\
<Key>Pause: string(0x1b) string("[34~") \n\
<Key>Insert: string(0x1b) string("[2~") \n\
<Key>Delete: string(0x1b) string("[3~") \n\
<Key>Home: string(0x1b) string("[1~") \n\
<Key>End: string(0x1b) string("[4~") \n\
<Key>Prior: string(0x1b) string("[5~") \n\
<Key>Next: string(0x1b) string("[6~") \n\
<Key>BackSpace: string(0x7f) \n\
<Key>Num_Lock: string(0x1b) string("OP") \n\
<Key>KP_Divide: string(0x1b) string("Ol") \n\
<Key>KP_Multiply: string(0x1b) string("Om") \n\
<Key>KP_Subtract: string(0x1b) string("OS") \n\
<Key>KP_Add: string(0x1b) string("OM") \n\
<Key>KP_Enter: string(0x1b) string("OM") \n\
<Key>KP_Decimal: string(0x1b) string("On") \n\
<Key>KP_0: string(0x1b) string("Op") \n\
<Key>KP_1: string(0x1b) string("Oq") \n\
<Key>KP_2: string(0x1b) string("Or") \n\
<Key>KP_3: string(0x1b) string("Os") \n\
<Key>KP_4: string(0x1b) string("Ot") \n\
<Key>KP_5: string(0x1b) string("Ou") \n\
<Key>KP_6: string(0x1b) string("Ov") \n\
<Key>KP_7: string(0x1b) string("Ow") \n\
<Key>KP_8: string(0x1b) string("Ox") \n\
<Key>KP_9: string(0x1b) string("Oy") \n
! <Key>Up: string(0x1b) string("[A") \n\
! <Key>Down: string(0x1b) string("[B") \n\
! <Key>Right: string(0x1b) string("[C") \n\
! <Key>Left: string(0x1b) string("[D") \n\
*visualBell: true
*saveLines: 1000
*cursesemul: true
*scrollKey: true
*scrollBar: true
Note that real VT220 terminals use shifted function keys to mean something different: the user-programmable keys (i.e., DECUDK). Modern xterm supports this, but the translations do not (they're using shift to select F13 to F20).
Here's another one, from Robert Ess <ress@spd.dsccc.com>:
#!/bin/sh
# vax
# 09-17-96 Bob Ess - initial creation
# 09-26-96 Shig Katada - Additional keybindings
#
# Script file to incorporate keybindings and command line
# options for connecting to a VAX node
# Usage statement
Usage(){
echo
echo " Usage : vax -options"
echo
echo " Options: -80 for 80 column terminal"
echo " -132 for 132 column terminal"
echo " -fg colorname"
echo " -bg colorname"
echo " -fn fontname"
echo " -fb bold fontname"
echo " -host [altair] [devel] [leonis] [castor]"
echo ""
echo " Example: \"vax -80 -fg white -bg black -fn 9x15 -fb 9x15b -host castor\""
echo " Starts a VAX session with an 80 column terminal"
echo " with a black background, white foreground, a normal"
echo " font of 9x15 and a bold font of 9x15b, and connects"
echo " to the node 'castor'"
echo
echo " If you need additional help, please call Workstation"
echo " Services at x92396."
echo
exit 1
}
# Default to a black foreground with a white background.
# Use the 9x15 and 9x15bold fonts. Connect to castor by default.
#
FG=black
BG=white
HOST=castor
FONT=9x15
BFONT=9x15bold
COLS=80
# Parse the command line arguments
#
while [ $# != 0 ];
do
case $1 in
-80) COLS=80
FONT=spc12x24c
BFONT=spc12x24b
shift
;;
-132) COLS=132
FONT=9x15
BFONT=9x15b
shift
;;
-fg) shift
FG=$1
shift;;
-bg) shift
BG=$1
shift;;
-fn) shift
FONT=$1
shift;;
-fb) shift
BFONT=$1
shift;;
-host) shift
HOST=$1
shift;;
-help) Usage;;
*) Usage;;
esac
done
xterm -title "VAX" -sb -sl 1200 -geo ${COLS}x24 -fg ${FG} -bg ${BG} \
-cr red -fn ${FONT} -fb ${BFONT} -xrm \
'XTerm*VT100.translations: #override \n\
<Key>Insert: string(\001) \n\
Shift <Key>Up: scroll-back(1,lines) \n\
Shift <Key>Down: scroll-forw(1,lines) \n\
Shift <Key>Right: string(0x1b) string("f") \n\
Shift <Key>Left: string(0x1b) string("b") \n\
Shift <Key>Delete: string(0x1b) string(0x08) \n\
Shift <Key>Tab: string(0x1b) string("*") \n\
<Key>0x1000FF0D: scroll-back(1,page) \n\
<Key>0x1000FF0E: scroll-forw(1,page) \n\
<Key>0x1000FF09: string(\010) \n\
<Key>0x1000FF0A: string(\005) \n\
<Key>BackSpace: string(0xff) \n\
<Key>Select: select-start() \n\
<Key>0x1000FF02: select-end(PRIMARY,CUT_BUFFER0) \n\
Meta <Key>0x1000FF02: select-end(CLIPBOARD) \n\
<Key>0x1000FF04: insert-selection(PRIMARY,CUT_BUFFER0) \n\
Meta <Key>0x1000FF04: insert-selection(CLIPBOARD) \n\
<Key>F1: string(0x1b) string("OP") \n\
<Key>F2: string(0x1b) string("OQ") \n\
<Key>F3: string(0x1b) string("OR") \n\
<Key>F4: string(0x1b) string("OS") \n\
<Key>F5: string(0x1b) string("OA") \n\
<Key>F11: string(0x1b) string("[23~") \n\
<Key>F12: string(0x1b) string("[24~") \n\
<Key>KP_0: string(0x1b) string("Op") \n\
<Key>KP_1: string(0x1b) string("Oq") \n\
<Key>KP_2: string(0x1b) string("Or") \n\
<Key>KP_3: string(0x1b) string("Os") \n\
<Key>KP_4: string(0x1b) string("Ot") \n\
<Key>KP_5: string(0x1b) string("Ou") \n\
<Key>KP_Divide: string(0x1b) string("OP") \n\
<Key>KP_Multiply: string(0x1b) string("[29~") \n\
<Key>KP_Enter: string(0x1b) string("OM") \n\
<Key>KP_Subtract: string(0x1b) string("Om") \n\
<Key>KP_Add: string(0x1b) string("Ol") \n\
<Key>KP_Decimal: string(0x1b) string("On") \n\
<Btn1Down>: select-start() \n\
<Btn1Motion>: select-extend() \n\
<Btn1Up>: select-end(PRIMARY,CUT_BUFFER0) \n\
Button1<Btn2Down>: select-end(CLIPBOARD) \n\
Button1<Btn2Up>: ignore()' \
-e telnet $HOST &
Finally (for the moment) is a further modification of Robert Ess's script by Erik Ahlefeldt, <oahlefel@metz.une.edu.au>. From his readme file, for vmsterm:
This script is for people who wish to connect from a Linux or Unix computer to a VMS computer using telnet and get a good VT100 or VT220 emulation. The key mappings have been specifically designed to emulate the VT terminal auxiliary numeric keypad, so that you can use VMS EDT and TPU editors, as well as the many VMS applications use keys PF1 to PF4. The script should work with any recent version of Xterm using a standard extended IBM PC keyboard or a Sun keyboard.
About the keymappings. First the auxiliary numeric keypad. My prime objective with these mappings was to produce a setup that I could use with the EDT and TPU editors which make extensive use of the numeric keypad. The top row of keys PC numeric keypad (Num Lock, Divide, Multiply, Subtract) are where you find PF1, PF2, PF3, PF4 on a VT keyboard, so I have mapped them to PF1 thru PF4. The PC numeric keypad Add key (+) takes up the space of two keys which are Minus and Comma on the VT keyboard – I have mapped it to Comma (Delete Character in the EDT editor). I have then used the PC Pause key to map to VT key Minus (Delete Word in the EDT editor). The remaining keys on the auxiliary numeric keypad are the same for PC and VT.
The six keys between the main and numeric keypads on the PC (Insert, Home, Page Up, Delete End, Page Down) are usually mapped to the VT keys by either position or by (approximate) function. As I rarely use these keys I have mapped them by function as follows: PC key Insert to VT Insert Here, PC Home to VT Find, PC Page Up to VT Prev, PC Delete to VT Remove, PC End to VT Select, PC Page Down to VT Next.
- Function keys.
- There are 12 function keys on the PC keyboard and 20 on the VT keyboard, so I map PC F1 thru F12 to VT F1 thru F12 (except for F1 thru F5 as noted below) and PC Shift F1 thru Shift F10 to VT F11 thru F20.
The VT keys F1 thru F5 are local hardware function keys so there is nothing to emulate, however some PC to VT emulations in the past have mapped PF1 thru PF4 here, so I have done that too, even though they are already mapped on the auxiliary numeric keypad.
- Xterm functionality.
- You lose some xterm functions when you remap the keyboard, however this script implements a scroll back buffer of 1000 lines which you scroll through using Shift and Up (a.k.a. Up Arrow or Cursor Up key) or Shift and Down.
a summary of the keyboard mapping:
PC Key maps to VT Key. ------ ------ F1 PF1 F2 PF2 F3 PF3 F4 PF4 F5 unused F6 F6 F7 F7 F8 F8 F9 F9 F10 F10 F11 F11 F12 F12 Shift F1 F11 Shift F2 F12 Shift F3 F13 Shift F4 F14 Shift F5 F15 (Help) Shift F6 F16 (Do) Shift F7 F17 Shift F8 F18 Shift F9 F19 Shift F10 F20 Shift F11 F11 Shift F12 F12 Print Help (F15) Cancel Do (F16) Pause Keypad Minus Insert Insert Here Delete Remove Home Find End Select Prior Prev Next Next BackSpace BackSpace (sends DEL - ascii 127) Num_Lock PF1 KP_Divide PF2 KP_Multiply PF3 KP_Subtract PF4 KP_Add Keypad Comma KP_Enter Enter KP_Decimal Period KP_0 Keypad 0 KP_1 Keypad 1 KP_2 Keypad 2 KP_3 Keypad 3 KP_4 Keypad 4 KP_5 Keypad 5 KP_6 Keypad 6 KP_7 Keypad 7 KP_8 Keypad 8 KP_9 Keypad 9 Up Up Shift Up Scroll Back Down Down Shift Down Scroll Forward Right Right Left Left
and the script:
#!/bin/sh
# vmsterm
# from an original script by Bob Ess
# key translations by Erik Ahlefeldt
#
# Script file using Xterm and telnet to connect to a VMS host
# and give a decent vt220 emulation.
#
# Usage statement
Usage(){
echo
echo " Usage : vmsterm -options"
echo
echo " Options: -80 for 80 column terminal"
echo " -132 for 132 column terminal"
echo " -bg colorname"
echo " -fg colorname"
echo " -fn fontname"
echo " -fb bold fontname"
echo " -host [crusher.saltmine.com] [earth] [192.168.7.7]"
echo ""
echo " Example: \"vmsterm -80 -fg white -bg black -fn 9x15 -fb 9x15b -host earth\""
echo " Starts a VMS session with an 80 column terminal"
echo " with a black background, white foreground, a normal"
echo " font of 9x15 and a bold font of 9x15b, and connects"
echo " to the node 'earth'"
echo ""
echo " Example: \"vmsterm -host earth\""
echo " Starts a VMS session with default terminal settings "
echo ""
echo " Example: \"vmsterm -help\""
echo " Displays vmsterm options "
echo
exit 1
}
# Default to a black foreground with a white background.
# Use the 9x15 and 9x15bold fonts. Connect to 192.168.3.3 by default.
#
FG=black
BG=white
HOST=192.168.3.3
FONT=9x15
BFONT=9x15bold
COLS=80
# Parse the command line arguments
#
while [ $# != 0 ];
do
case $1 in
-80) COLS=80
FONT=spc12x24c
BFONT=spc12x24b
shift
;;
-132) COLS=132
FONT=9x15
BFONT=9x15b
shift
;;
-fg) shift
FG=$1
shift;;
-bg) shift
BG=$1
shift;;
-fn) shift
FONT=$1
shift;;
-fb) shift
BFONT=$1
shift;;
-host) shift
HOST=$1
shift;;
-help) Usage;;
*) Usage;;
esac
done
xterm -title "VMSTERM" -sb -sl 1000 -geo ${COLS}x24 -fg ${FG} -bg ${BG} \
-cr blue -fn ${FONT} -fb ${BFONT} -xrm \
"XTerm*vt100.translations: #override \n \
~Shift <Key>F1: string(0x1b) string("OP") \n \
~Shift <Key>F2: string(0x1b) string("OQ") \n \
~Shift <Key>F3: string(0x1b) string("OR") \n \
~Shift <Key>F4: string(0x1b) string("OS") \n \
~Shift <Key>F5: string("Break") \n \
~Shift <Key>F6: string(0x1b) string("[17~") \n \
~Shift <Key>F7: string(0x1b) string("[18~") \n \
~Shift <Key>F8: string(0x1b) string("[19~") \n \
~Shift <Key>F9: string(0x1b) string("[20~") \n \
~Shift <Key>F10: string(0x1b) string("[21~") \n \
~Shift <Key>F11: string(0x1b) string("[23~") \n \
~Shift <Key>F12: string(0x1b) string("[24~") \n \
Shift <Key>F1: string(0x1b) string("[23~") \n \
Shift <Key>F2: string(0x1b) string("[24~") \n \
Shift <Key>F3: string(0x1b) string("[25~") \n \
Shift <Key>F4: string(0x1b) string("[26~") \n \
Shift <Key>F5: string(0x1b) string("[28~") \n \
Shift <Key>F6: string(0x1b) string("[29~") \n \
Shift <Key>F7: string(0x1b) string("[31~") \n \
Shift <Key>F8: string(0x1b) string("[32~") \n \
Shift <Key>F9: string(0x1b) string("[33~") \n \
Shift <Key>F10: string(0x1b) string("[34~") \n \
Shift <Key>F11: string(0x1b) string("[28~") \n \
Shift <Key>F12: string(0x1b) string("[29~") \n \
<Key>Print: string(0x1b) string("[28~") \n \
<Key>Cancel: string(0x1b) string("[29~") \n \
<Key>Pause: string(0x1b) string("Om") \n \
<Key>Insert: string(0x1b) string("[2~") \n \
<Key>Delete: string(0x1b) string("[3~") \n \
<Key>Home: string(0x1b) string("[1~") \n \
<Key>End: string(0x1b) string("[4~") \n \
<Key>Prior: string(0x1b) string("[5~") \n \
<Key>Next: string(0x1b) string("[6~") \n \
<Key>BackSpace: string(0x7f) \n \
<Key>Num_Lock: string(0x1b) string("OP") \n \
<Key>KP_Divide: string(0x1b) string("OQ") \n \
<Key>KP_Multiply: string(0x1b) string("OR") \n \
<Key>KP_Subtract: string(0x1b) string("OS") \n \
<Key>KP_Add: string(0x1b) string("Ol") \n \
<Key>KP_Enter: string(0x1b) string("OM") \n \
<Key>KP_Decimal: string(0x1b) string("On") \n \
<Key>KP_0: string(0x1b) string("Op") \n \
<Key>KP_1: string(0x1b) string("Oq") \n \
<Key>KP_2: string(0x1b) string("Or") \n \
<Key>KP_3: string(0x1b) string("Os") \n \
<Key>KP_4: string(0x1b) string("Ot") \n \
<Key>KP_5: string(0x1b) string("Ou") \n \
<Key>KP_6: string(0x1b) string("Ov") \n \
<Key>KP_7: string(0x1b) string("Ow") \n \
<Key>KP_8: string(0x1b) string("Ox") \n \
<Key>KP_9: string(0x1b) string("Oy") \n \
~Shift <Key>Up: string(0x1b) string("[A") \n \
Shift <Key>Up: scroll-back(1,lines) \n \
~Shift <Key>Down: string(0x1b) string("[B") \n \
Shift <Key>Down: scroll-forw(1,lines) \n \
<Key>Right: string(0x1b) string("[C") \n \
<Key>Left: string(0x1b) string("[D")" \
-e telnet $HOST
The control sequences for doing this are documented in ctlseqs.ms.
The usual context for this question is setting the title according to the current working directory. People post answers to this periodically on the newsgroups. Here is one that I have seen, from Roy Wright <nobody@roystoy.dseg.ti.com>. In your /etc/profile after:
if [ "$SHELL" = "/bin/pdksh" -o "$SHELL" = "/bin/ksh" ]; then
PS1="! $ "
elif [ "$SHELL" = "/bin/zsh" ]; then
PS1="%m:%~%# "
elif [ "$SHELL" = "/bin/ash" ]; then
PS1="$ "
else
PS1='\u@\h:\w\$ '
fi
add:
if [ "$TERM" = "xterm" ]; then
PS1="\033]2;\u@\h:\w\007bash$ "
fi
The terminator "\007" is a problem area. XTerm historically uses this character, though it is non-ANSI. The "correct" character should be a "\233" string terminator, or "\033\\", which is the 7-bit equivalent. Modern xterm recognizes either (the "\007" or string terminator); waiting for the first of these.
You may have resource or environment problems that prevent you from setting the title at all. Newer xterms (starting somewhere in X11R5) use the $LANG variable. If your locale is incorrectly installed, you will be unable to set the xterm's title. As noted by Mikhail Teterin <mi@rtfm.ziplink.net>: Make sure that the locale (LANG and/or LOCALE environment variable) is known to X Window System. Check ${X11ROOT}/lib/X11/locale.* for it. If it is not listed in either one of the files, find the nearest match and add an alias to it. Restart X if you have made changes.
On a related note, some people want to know how to read the title from an xterm. This works for modern xterm and dtterm, but not for other variations:
#!/bin/ksh
# Echo the current X term title bar to standard output.
# Written by Icarus Sparry <icarus@bath.ac.uk> 11 Apr 1997
#
exec </dev/tty
old=$(stty -g)
stty raw -echo min 0 time ${1-10}
print "\033[21t\c" > /dev/tty
IFS='' read -r a
stty $old
b=${a#???}
print -R "${b%??}"
But it is possible to avoid escape sequences altogether (from Hemant Shah <shah@typhoon.xnet.com>):
$ xprop -id $WINDOWID | grep WM_NAME WM_NAME(STRING) = "this is my title" current_title=$(xprop -id $WINDOWID | grep WM_NAME | cut -d= -f2)
Here's another source of information: Xterm-Title HowTo
Standard xterm does not implement a blinking cursor. Some of the variations do: dtterm, GNOME Terminal, and modern xterm (from mid 1999, patch 107).
Your copy of xterm may not have enough permissions to use existing pty's: