Menu

#1 cheap xterm titles with BASH

open
nobody
None
1
2006-08-06
2001-10-25
Gene Cash
No

I think this might belong in the FAQ, as it's not a
patch but more of a useful tip, but I don't know who to
submit it to.

I know a lot of folk use those horrid ANSI escape
sequences to put their $PWD or whatever in their xterm
title. This has the problem of playing with BASH's
idea of where the cursor is, and how long the prompt
is, and causes lots of problems. It ends up being a
bigger hassle than it's worth.

This is a shame because it is useful when switching
windows with alt-tab or the window list. You can
differentiate between the many xterms you may be
running.

I noticed that xterm sets a WINDOWID variable, and BASH
has a PROMPT_COMMAND variable which (if set) it tries
to execute as a command each time it displays the
prompt.

Well, with icesh you can trash the ANSI crap.

I put the following in my .bash_profile:

if [ -n "$DISPLAY" ] ; then
PROMPT_COMMAND="icesh -window $WINDOWID
setWindowTitle \"xterm - \$PWD\""
fi

It was non-obvious for me but really useful. I do love
ICEWM. Thanks.

Discussion

  • Marko Macek

    Marko Macek - 2002-05-01
    • priority: 5 --> 1
     
  • Mathias Hasselmann

    Logged In: YES
    user_id=7017

    Hmm... Should go to the FAQ, IMHO...

     
  • Marko Macek

    Marko Macek - 2002-12-25

    Logged In: YES
    user_id=1814

    Actually, it would be nice to have a command that only links
    to X and only does the title setting. I had one somewhere a
    long ago.

    I didn't know about PROMPT_COMMAND then (had to kludge it),
    but now it may be a good idea to include it.

     
  • Marko Macek

    Marko Macek - 2006-08-06
    • labels: 310627 -->
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.