Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to find a way to quickly change the title of a Gnome Terminal 2.32.1 window since I have quite a few open and I'm editing different files in each, using a compiler in one, tailing log files in others and so forth. Hence it's a pain looking for the window I want when they all say pax@pax-desktop:~.

This question led me to try xtitle but, for some reason it's not actually changing the title.

Executing xtitle xyzzy results in no visible feedback but piping it through od confirms it's outputting an escape sequence (which I'm assuming is correct, though I haven't checked in detail):

pax@pax-desktop:~/porn_dir$ xtitle xyzzy | od -xcb
0000000    5d1b    3b32    7978    7a7a    0779    5d1b    3b31    7978
        033   ]   2   ;   x   y   z   z   y  \a 033   ]   1   ;   x   y
        033 135 062 073 170 171 172 172 171 007 033 135 061 073 170 171
0000020    7a7a    0779
          z   z   y  \a
        172 172 171 007
0000024

I can go into the menu Terminal | Set Title and change it okay from there but I would much prefer a command-line solution since I can do it automatically (such as create a vi alias which sets the title to vi filename before running the editor and resets it on exit).

In the profile preferences, the initial title is set to Terminal and the When terminal commands set their own titles is set to Replace initial title. There's also only the one profile Default which is the one I'm using.

share|improve this question
Wow, a whole hour and no answers yet. On SO, I would have had about ten answers by now along with a lively debate going on in the comments, some questioning my sanity and/or parentage. Oh well, guess I'll need to learn some patience :-) In any case, I've sorted it now, see below. – paxdiablo Jan 6 '12 at 2:51

1 Answer

up vote 1 down vote accepted

Aaarrrggghhhhhh !!!

Turns out xtitle is working fine and changing the title. However, there's a segment in the default .bashrc as follows:

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

which sets the prompt up so that it changes the title back to the usual value every time it asks the user for input.

By commenting the PS1=... line above out, the title remains set to whatever you choose.

share|improve this answer
AFAIK, accepting your own answer is OK and yields no side effects. – aquaherd Jan 9 '12 at 21:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.