It is currently Thu, 20 Jan 2022 05:04:08 GMT

Author Message
 Xterm's and dynamic title strings

I am trying to dynamically change the title of my xterm window to indicate what
directory I am in.  I have seen this done before, but the man page for xterm
provides little clues as to how to do this....

I am tired of have the cwd output in my prompt and I have all of the landscape in
the title bar that would loved to be better utilized than simply stating "xterm".

Thank You

Matt Goldensohn

 Tue, 15 Dec 1998 03:00:00 GMT   
 Xterm's and dynamic title strings
In article <>,

In ksh, you can set the title by:

  echo "\033]2;${PWD}\007\c"

In other shells, it may be necessary to use echo -n rather than \c to
suppress the newline, and you may have to replace ${PWD} with another
appropriate variable or `pwd`.  Next construct an alias or function to
replace the 'cd' builtin which does a cd, and then sets the title to the
current directory if successful.  This and other xterm escape sequences
are documented in the file which comes with the X distribution.


Mike Shapiro, Systems Programmer. Dept. of Computer Science.

 Wed, 16 Dec 1998 03:00:00 GMT   
 Xterm's and dynamic title strings
On 29 Jun 1996 17:49:15 GMT, Mike Shapiro <> wrote:

here is my {t}csh alias

alias header    '/bin/echo "\033]2;\!*\007\c"'

/*  Mike D. Kail                 |  voice:  (619) 793-3359  */
/*  Unix System Administrator    |  fax:    (619) 793-2950  */
/*  FIRST VIRTUAL Holdings Inc.  |  e-mail:   */

 Wed, 16 Dec 1998 03:00:00 GMT   
 Xterm's and dynamic title strings

The following does what you want:

echo "ESC]2;TEXT^G"

or more precisely:


alias newcd 'cd \!*;echo -n ESC]2\;$cwd^G'

In most shells a ^V lets you enter an escaped character, in emacs
a ^Q does the same.

My information on this comes from The X Journal, Vol 5 No 4.


 Fri, 18 Dec 1998 03:00:00 GMT   
 Xterm's and dynamic title strings

If you're using tcsh, you can just add this alias and it will get run
every time the cd command is successfully executed.

alias cwdcmd 'if ($TERM == "xterm") echo -n "^[]2;${HOST}:$cwd^G"'

Note that this only changes the title in the tab, (under twm) and not
the title used by the window manager.  To do that, change the 2 to a 1.

Mark Frazer   Electrical and Computer Engineering   University of Waterloo

 Sat, 19 Dec 1998 03:00:00 GMT   
   [ 5 post ] 

Similar Threads

1. active xterm and dtterm title string

2. How to change xterm title bar string?

3. Using tcsh prompt string in xterm title

4. Prompt string to change xterm title?

5. Change xterm's title

6. can't change gnome/sawfish xterm titles

7. How do I change the xterm title after it's created

8. Urgent: How to change xterm's title bar string?

9. HELP : Set Window Title Bar Strings with XLIB functions

10. Title string in header page

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software