Terminal.app is not your grandfather's VT100 terminal

Speeding it up: Set the shell to /bin/bash -l and run sudo rm -rf /private/var/log/asl/*.asl to remove Apple System Log files it insists on skimming upon launch.

(snarfed from uucee for quick reference)

Now that has some "serious" competition in the form of xterm as part of the X11 release there could be some saving graces keeping still relevant.

  • emulates an extended set of the VTxxx series commands, closely resembling dtterm

Yes, that's a surprise, considering all the effort that's gone into hacking vt100-based colour termcaps etc. The simplest way to enable colour in is to set TERM to "dtterm". Works like a charm. emacs, lynx (Fink dist), GNU ls, all in glorious three-bit colour. "xterm-color" also works but some features such as visual bell (used by vi) will be missing.

  • Custom info picked up by from the execution context

With it's easy to customise the title bar to show the current process, tty, window size etc. with just a click on a checkbox. Naturally die-hard xterm fans have a way to do just about anything in xterm but for such simple tasks provides a feature that's easy to use for mere mortals.

There seems to be more functionality in than there is in xterm. Not a small feat, considering that the current author of vttest also has code in xterm. Looks like the only thing cannot handle is X Window mouse location reporting. infocmp vt100 dtterm and infocmp xterm dtterm used with vttest have resemble dtterm the closest.

Apparently Apple ships a nice terminal emulator that complements xterm but for some reason is tagged only a vt100 emulator. Maybe all this undocumented functionality will be traded for Tektronix emulation in the next rev?

Department of Tricks and Tips

To automagically have start up with TERM set to dtterm by default, here's a clipped prefs file.

~/Library/Preferences/com.apple.Terminal.plist

<?xml version="1.0" encoding="UTF-8"?>
  <plist version="1.0">
  <dict>
    <key>Columns</key>
    <string>80</string>
    <key>Rows</key>
    <string>42</string>
    <key>Shell</key>
    <string>/usr/bin/env TERM=dtterm /usr/bin/login -pf YOUR_USERID</string>
    <key>ShellExitAction</key>
    <string>2</string>
    <key>TitleBits</key>
    <string>104</string>
    <key>StringEncoding</key>
    <string>5</string>
    <key>SaveLines</key>
    <string>-1</string>
  </dict>
  </plist>

Shortcuts for under the File - Library menu

~/Library/Application Support/Terminal/UTF-8.term

<?xml version="1.0" encoding="UTF-8"?>
  <plist version="1.0">
  <dict>
    <key>WindowSettings</key>
    <array>
      <dict>
        <key>StringEncoding</key>
        <string>4</string>
      </dict>
    </array>
  </dict>
  </plist>
 ~/Library/Application Support/Terminal/ssh-hypsis.term

 <?xml version="1.0" encoding="UTF-8"?>
  <plist version="1.0">
  <dict>
    <key>WindowSettings</key>
    <array>
      <dict>
        <key>Shell</key>
        <string>/usr/bin/env TERM=dtterm /usr/bin/ssh hypsis</string>
      </dict>
    </array>
  </dict>
  </plist>

Basically any and all prefs can be picked out one by one and made into a custom configuration with the rest of the prefs reverting to defaults.

These settings can also be opened from the command prompt:

alias utf8 'open ~/Library/Application\ Support/Terminal/UTF-8.term'
alias hypsis 'open ~/Library/Application\ Support/Terminal/ssh-hypsis.term'

Support for dtterm may vary on a UNIX flavour by flavour basis so it may be necessary to revert TERM to "xterm-color" on remote systems.

.login

set xterm_for_dtterm = 1

if ($?TERM) then
  if ("$TERM" == "dtterm" && $xterm_for_dtterm ) then
    setenv TERM "xterm-color"
  endif
endif

unset xterm_for_dtterm

Setting the window title

Other threads have probably exhausted the "how do I set my window title" topic yet here are the instructions again, but with a twist at the end.

.tcshrc

setenv WHOAMI `whoami`
if ($?TERM) then
  if ("$TERM" == "dtterm") then
    set prompt = "%{^[\]2;\[$WHOAMI@%m\]^G%}\[%m\:%c3\] %n%# "
  endif
endif

.login

if ($?TERM) then
  if ("$TERM" == "dtterm") then
    set prompt = "%{^[\]2;\[$WHOAMI@%m\]^G%}\[%m:%c3\] %n%# "
  endif
endif

# (^[ is ESC, 0x1B, ^G is BELL, 0x07;
# usually typed in as ^QESC, ^Q^G (emacs), ^VESC, ^VG (vi))

Why have the same code in both .login and .tcshrc? To have su root change the title as well, provided the account's .tcshrc file contains the lines above. If a remote account also has these lines in the .login/.tcshrc config then going back and forth in the session should keep the title always current.

Another way to accomplish the above is to use a tcsh precmd alias:

alias precmd 'echo -n "^[]2;[$WHOAMI@`date`]^G"'

For static text using just the prompt is sufficient.

Fun with shell aliases

Taking advantage of the dtterm escape sequences, these could come in handy:

alias dock 'echo -n "^[[2t"'
alias lower 'echo -n "^[[6t"'
alias raise 'echo -n "^[[5t"'
alias 42x80 'echo -n "^[[8;42;80t"'
alias maxh 'echo -n "^[[8;0;80t"'
alias maxw 'echo -n "^[[8;24;0t"'
alias zoom 'echo -n "^[[3;0;t^[[8;0;0t"'

A "background" make alias?

alias bgmake 'dock; make \!*; raise'

Other esoteric terminal escape codes that work with can be gleaned from vttest.log produced with vttest -l.

That's way too much time spent in and not enough /Project Builder time.

Your mileage may vary, especially if using Bourne shell/bash/C shell.


uucee mac com 20030123

Resources:

This page is referenced in: