Use xtermcontrol with Terminal.app

Feb 25, '05 08:20:00AM

Contributed by: gshenaut

There is a utility designed for use with xterm(1), the standard X-Windows terminal program, called xtermcontrol. It's source can be downloaded from the developer's website , and it may also be available as a Fink package. On my 10.3.8 system, it compiled and ran out of the box.

Anyway, it turns out that since Terminal.app implements a subset of the standard xterm/ANSI escape sequences, many of the functions of xtermcontrol will work inside a Terminal window (of course, they all work inside an xterm window). I tried it with iTerm, and it doesn't work well; I haven't tried other terminal-style programs. xtermcontrol checks the TERM variable and will complain if it doesn't find xterm in it. In my Terminal windows, I always set TERM=xterm-color anyway.

For example, you can set the window title with:

xtermcontrol --title="My Window Title"
Or set the window size and location with:
xtermcontrol --geometry=80x25+200+400
You can also find out the current size and so on. You can find out all of the commands using the --help flag. The color and font commands don't seem to work, but many of the others do. You just have to use trial and error. A visually interesting command line to try is:
say goodbye ; xtermcontrol --iconify ; sleep 5 ; xtermcontrol \
 --de-iconify; say hello
If you were sufficiently interested, and had too much time on your hands, you could choreograph a whole "Terminal ballet" with xtermcontrol and sleep (with xterm, you also can change the colors "on the fly").

Caution: A few of the unimplemented commands will cause the Terminal window to get hung (waiting to read a response from the window that doesn't come). The fix is to do a ps a command from another window, and kill the stuck xtermcontrol process.

This program might be especially useful for things like putting the date and time in the title, and from within shellscript.command applications.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050223142229375