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
Tom
  • 5,017

6 Answers6

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

ronan_mac
  • 431
  • 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 '16 at 23:01
  • 1
    works for me on ubuntu 16.04! – Programster Jun 02 '16 at 21:22
  • 1
    works like charm !! – sharadendu sinha Aug 30 '16 at 13:42
  • How do I change the title while a foreground process is running, which I don't want to abort? – Jānis Elmeris Nov 02 '17 at 05: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 02 '17 at 09: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.

A.B.
  • 90,397
  • 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 '15 at 14:15
  • 2
    @Tom Write a bug report =) – A.B. Apr 30 '15 at 14:16
  • There is a good commandline-based answer if you scroll down: http://askubuntu.com/a/702773/130331 – ahcox Feb 20 '16 at 23:03
  • 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!) – ShinTakezou Mar 14 '16 at 20:44
  • 2
    Usually new releases add and not remove features. – angelcervera Mar 31 '16 at 09:27
  • Oh, the Gnome's war on features again... At least we have a workaround. – Calmarius Aug 18 '16 at 10:11
  • 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 '16 at 14:05
  • @ShinTakezou I don't know who's been making the calls at gnome but it's been one chain of idotic decision after another since switching over to gnome 3. I've never seen a develloper mutilate his own sweat and toil more than gnome. They started out with such a good desktop and all they have to show in each release is take features off. I think someone at gnome is having a good laugh at this very elaborate practical joke. 7 years into the life cycle of gnome 3 and all we have to show for it is 75% less features than gnome-shell 3.01 and nautilus whatever. – thebunnyrules Dec 21 '17 at 09:10
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 ;-)

muru
  • 197,895
  • 55
  • 485
  • 740
  • 1
    How can I change Tab Title in roxterm? I couldn't find it. – Halil Sep 02 '15 at 07:19
  • will work for 16.04 too – prusswan Mar 19 '16 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 '17 at 05:45
  • 1
    RoxTerm is awesome and still works but sadly won't be continuing much longer :sadface: : https://sourceforge.net/p/roxterm/discussion/422638/thread/60da6975/ – Williams Aug 29 '17 at 04:28
  • I've switched to Terminator since then, and didn't have to use RoxTerm any more.... – Michael Opdenacker Nov 16 '17 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").

muru
  • 197,895
  • 55
  • 485
  • 740
Traumflug
  • 119
  • 2
  • 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 '16 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?

Traumflug
  • 119
  • 2