Setting your terminal title in bash

I didn’t really want to write three articles about bash in a row, but
after my last article about Bash prompts Ralph Aichinger emailed me
asking about a feature he had in zsh, where his xterms show him the
current process and whether it was possible to do that in Bash. Never one to
refuse a challenge, I had a go and my
latest article
is the result.

4 thoughts on “Setting your terminal title in bash

  1. You should add a c to your echo command so you dont’ get spurious newlines.

    trap ‘echo -e “e]0;$BASH_COMMAND07″‘ DEBUG
    becomes
    trap ‘echo -e “e]0;$BASH_COMMAND07c”‘ DEBUG

  2. Yes, crap, I’d forgotten I’d added on a -n to echo to fix that. Thanks for reminding me. I’ve updated the article.

  3. Hi,
    I liked having the command in the terminal window.
    It looks however like it is messing up things like this:

    cd $( pwd )

    Using rxvt on cygwin gives an error when running the above. Apparantly because the terminal title string is prepended to the output of pwd.

  4. If BASH_COMMAND has some parts that are back-ticked, they will get executed, which may damage whatever is trying to run.
    It may also send error messages (this is what made the phenomenon visible in the first place).
    Any way to expand BASH_COMMAND to a string value without executing anything?

    E

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.