Products
and Services Support
and Docs Training Partner Programs About Red
Hat
  download storecart
red hat logo
redhat.comredhat network

Red Hat Documentation

Overview | HOWTOs | mini-HOWTOs | FAQs | Linux Man-Pages

How to change the title of an xterm: Printing the current job name Next Previous Contents

5. Printing the current job name

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.

5.1 zsh

zsh provides an ideal builtin function for this purpose:

preexec()   a function which is just before a command is executed
$*,$1,...   arguments passed to preexec()
Thus, we can insert the job name in the title as follows:
case $TERM in
    xterm*)
      preexec () {
        print -Pn "\e]0;$*\a"
      }
    ;;
esac
Note: the preexec() function appeared around version 3.1.2 of zsh, so you may have to upgrade from an earlier version.

5.2 Other shells

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.


Next Previous Contents

 

 


 
© 2001 Red Hat, Inc. All rights reserved.
About Red Hat  :  Legal statement  :  Privacy statement  :  Y2K statement  :  Contact Red Hat