Dec 31, 2011

Dynamimcally setting the title of an xterm (and compatible) window

Keywords: xterm, konsole, title, dynamic, .tcshrc
Depends on: tcsh
Download:  .tcshrc -fragment

I was looking to customize my Konsole's title.  I wasn't entirely happy with the default.  I wanted `~' to be displayed when I was in my home directory and I didn't want to display my fully qualified host name.

What I wanted was the following when in my Home directory on my machine named `zoom':  pablo@zoom:~

A quick Web search (keywords:  xterm title escape sequence) provided the necessary escape sequence - http://tldp.org/HOWTO/Xterm-Title-3.html

Reading tcsh's man page, I found the precmd variable.  The commands specified in precmd are executed before each prompt is printed.  Perfect.

The .tcshrc fragment, I placed at the top of my .tcshrc file to ensure it gets executed first when a terminal is started.

The final piece is to ensure Konsole is configured to display titles:
  1. Start a Konsole terminal
  2. Left-click inside the terminal to bring up a menu of options, select Configure Current Profile ...
  3. Select the Tabs tab and
  4. Set both Tab title format: and Remote tab title format: to Window Title Set by Shell

No comments:

Post a Comment