38

In Ubuntu 14.10, if I had multiple Terminal Tabs open, I could right-click a Terminal tab and rename it. In Ubuntu 15.04 I can't find this feature.

Is there a easy way to get it back?

This is the current version:

$ gnome-terminal --version
GNOME Terminal 3.14.2

6 Answers 6

33

The .bashrc solution proposed by Kirby worked for me:

set-title(){
  ORIG=$PS1
  TITLE="\e]2;$@\a"
  PS1=${ORIG}${TITLE}
}

then from my prompt: $ set-title test-title

5
  • 3
    Works for me fine on 15.10, the only caveat being that every time you run it you append to PS1, so don't do this from a script. After I called it a few times with set-title "longer and ": echo $PS1 \[\e]0; \u@\h: \w \a\]\u@\h:\w\[\033[m\]$(__git_ps1)$ \e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a\e]2;longer and \a
    – ahcox
    Feb 20, 2016 at 23:01
  • 1
    works for me on ubuntu 16.04! Jun 2, 2016 at 21:22
  • 1
    works like charm !! Aug 30, 2016 at 13:42
  • How do I change the title while a foreground process is running, which I don't want to abort? Nov 2, 2017 at 5:49
  • 1
    I think you can do it by pausing the process using Control + Z, then set-title X, then fg to resume the process.
    – ronan_mac
    Nov 2, 2017 at 9:09
21

Answered here

I quote:

The user title code was removed1 from gnome-terminal 3.14. There's only one way to set the title, using an escape sequence - e.g. with bash:

PROMPT_COMMAND='echo -ne "\033]0;YOUR TITLE GOES HERE\007"'

1: see gnome bug 724110 and gnome bug 740188.

8
  • 10
    Thanks for the answer. It's a shame it's gone, I hope they add it back in the next release, in the meantime, I'll use the escape sequence instead of the right-click method.
    – Tom
    Apr 30, 2015 at 14:15
  • 2
    @Tom Write a bug report =)
    – A.B.
    Apr 30, 2015 at 14:16
  • 13
    it's not just a shame: it's non-sense. I had the bad idea to “upgrade” from Debian Wheezy to Jessie just to have everything (not sure yet, indeed) I had before, but worse; bad decisions and silly flaws (e.g. in gdm3 the list of possible wm/sessions I have installed doesn't fit nor scroll, so it is simple cut and hence I can't choose all the wm I have). To me, GNOME is doomed since gnome-shell. It disappeared also the menu to open a new terminal in a new window or tab (but you still can do it via the shortcut. Why?! Replace everything with a big smart button: a click and it does anything!) Mar 14, 2016 at 20:44
  • 2
    Usually new releases add and not remove features. Mar 31, 2016 at 9:27
  • 2
    I made a command (a shell script) called tab that contains simply echo -ne "\033]0;$1\007" so now in any tab I can just run tab TABNAME to set the tab title. Not as convenient as rightclicking the tab to rename, but it will do for now. Thanks A.B.!
    – Brian Pipa
    Nov 16, 2016 at 14:05
18

I can't believe they removed such a user friendly feature like this one.

I'm switching to ROXTerm (http://roxterm.sourceforge.net), which does the job nicely. It's packaged in Ubuntu:

sudo apt-get install roxterm

Then, let the dinosaur continue its own way ;-)

5
  • 1
    How can I change Tab Title in roxterm? I couldn't find it.
    – Halil
    Sep 2, 2015 at 7:19
  • will work for 16.04 too
    – prusswan
    Mar 19, 2016 at 19:12
  • Wow, can't set a terminal to background with gnome-terminal and i did never understand why... it's a problem with the terminal itself. The devilspie terminal background works cool with roxterm.
    – m3nda
    Apr 15, 2017 at 5:45
  • 1
    RoxTerm is awesome and still works but sadly won't be continuing much longer :sadface: : sourceforge.net/p/roxterm/discussion/422638/thread/60da6975
    – Williams
    Aug 29, 2017 at 4:28
  • I've switched to Terminator since then, and didn't have to use RoxTerm any more.... Nov 16, 2017 at 10:43
14

I've tried RoxTerm as suggested above, with good results. But I settled on MATE Terminal, which is part of the MATE Project, a continuation of Gnome 2, on 15.04:

sudo apt-get install mate-terminal

That terminal is based on the Gnome Terminal code.


Commentary: It's hard to understand the mindset of the Gnome Terminal devs. There's a lot of discussion over there about "how" to name terminal tabs, and how it's difficult to get right. If that's the case, why make it harder for the user to name them? Not very smart at all.

6

Now I've investigated this for the better part of a day and finally found a way to set this title. It's done via escape sequences which start with \e]0; and end with a BEL character ( = \007 = \a). Unlike I stated above, communications from the shell back to the terminal application is possible, very limited, through such escape sequences (there are a few more).

About this from above:

PROMPT_COMMAND='echo -ne "\e]0;YOUR TITLE GOES HERE\a"'

It can work, but it doesn't always. PROMPT_COMMAND is a variable which contents is executed each time you send a command, so it also sends this escape sequence. However, this can be overriden by an escape sequence in the PS1 variable, which sets the command line prompt. This is why the above had no effect here.

From an older Ubuntu installation I grabbed this, which sets the command prompt (right part, after the ]) and also sends the required escape sequence (left part, up to and including the ]):

PS1="\[\e]0;\u@\h: \w\a\]\u@\h:\w\$ "

This likely performs better, because there's no need to interpret $PROMPT_COMMAND each time. It also has many more options, because Bash has more escape sequences here, e.g. \u for the current user name, \W for the current directory name or \w for the entire path of the current working directory, optionally trimmed to just the last few by the number in $PROMPT_DIRTRIM. See chapter PROMPTING in the Bash man page. Also take note that the escape sequence has additionally to be surrounded by \[ and \] here.

To set a fixed title, this works:

PS1="\[\e]0;YOUR TITLE GOES HERE\a\]\u@\h:\w\$ "

Enjoy!


During my investigation I also tried to understand gnome-terminal source code, which leads to vte source code and there the support for title setting and reading escape sequences is considered to be a security risk: See here (case 20, case 21) and here ("Window Title Reporting").

1
  • This sets the title but also wipes out any previous definition of PS1 for other uses such as setting a custom command prompt. I just tried adding your escape sequence on to the existing PS1 contents and it seems to work. Like this: PS1+="\[\e]0;YOUR TITLE GOES HERE\a\]\u@\h:\w\$ "
    – ahcox
    Feb 20, 2016 at 22:50
5

Setting $PROMPT_COMMAND as shown above has zero effect here. No surprise, because Bash runs inside the terminal and parent processes (here: gnome-terminal) can't read a child's environment on a unix-like OS. Using something more simple, like

PROMPT_COMMAND='echo bla'

Executes echo bla, nothing else happens.

Edit: one has to wrap this in escape sequences, see my other answer. Despite reading the child environment isn't possible, some communication back to the parent is, through these sequences.

In Gnome bug 740188 they talk about defining a title() function in .bashrc. A different one for each tab opened? Severe ugly hacking ahead, if possible at all!

Even other explanations on Stackexchange talk about setting $PS1 (and get upvoted). Sorry, no, that's not the title, that's the command prompt.

In short: they messed it up beyond repair to save a tiny bit of space in the preferences dialog. OMG

Now, the only chance to get a developer decision reverted is to kindle a severe shitstorm, else they simply close your bug report in seconds (tried many many many times). How would we create this shitstorm?

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .