Often a user will start a long-lived foreground job such as top
, an editor, an email client, etc, and wishes the name of the job to be shown in the title. This is a more thorny problem and is only achieved easily in zsh
.
zsh
provides an ideal builtin function for this purpose:
Thus, we can insert the job name in the title as follows:
preexec() a function which is just before a command is executed $*,$1,... arguments passed to preexec()
Note: the
case $TERM in xterm*) preexec () { print -Pn "\e]0;$*\a" } ;; esac
preexec()
function appeared around version 3.1.2 of zsh
, so you may have to upgrade from an earlier version.
This is not easy in other shells which lack an equivalent of the preexec()
function. If anyone has examples please email them to the author.