42

Is there way to set terminator (Version: 0.95ppa1) title of tabs to a different string via bash command-line (CLI)?

I plan to use this feature with AutoKey and I can open multiple machines at same time and set title to Name of the machine its connected to.

2
  • Thanks Paul. Let me try there. I found other useful utility mrxvt.. its seems to be very powerful.. Looks like, I'm going to migrate to mrxvt instead of terminator for this purpose.
    – Xprog
    Mar 17, 2011 at 22:34
  • Even I want this feature. Any luck finding solution for this ?
    – mac
    Mar 27, 2014 at 8:54

10 Answers 10

37
ORIG=$PS1
TITLE="\e]2;\"This is just crazy enough to work\"\a"
PS1=${ORIG}${TITLE}

Resets title to

"This is just crazy enough to work"

This should apply to all xterm-style terminal emulators.

4
  • 3
    excellent! Just visited this today :D Terminator on ubuntu works. Aug 20, 2012 at 16:47
  • How comes it works if I paste this directly in a terminal, but not not in a bash script ?
    – MickaelFM
    Apr 4, 2017 at 16:28
  • 1
    Do not use this method to setup your terminal's title since they will mess up your commands if you have typed long commands. Tested on Ubuntu 16.04 LTS x64 with terminator 0.98
    – zqer
    Sep 26, 2017 at 7:47
  • 1
    For the lazy (condensed to 1 line): ORIG=$PS1; TITLE="\e]2;\"This is just crazy enough to work\"\a"; PS1=${ORIG}${TITLE}. Replace This is just crazy enough to work with your desired tab title.
    – ximiki
    Jun 5, 2018 at 15:34
30

From the Terminator man pages,

Ctrl+Alt+W Rename window title.

Ctrl+Alt+A Rename tab title.

Ctrl+Alt+X Rename terminal title.

You can also launch a new instance with

$ terminator --title [title]

1
  • 3
    How to run this from the shell on tab already opened! That would be great.
    – Zioalex
    Oct 10, 2017 at 11:37
18

Add follwing in your .bashrc file by editing it using vim ~/.bashrc and use set_title to rename your tab:

set_title() 
{
ORIG=$PS1
TITLE="\e]2;$*\a"
PS1=${ORIG}${TITLE}
}

run source ~/.bashrc command after editing your .bashrc file

Ex.: set_title newtab will rename your current tab to newtab

working Properly in Gnome3.14 terminal and terminator 0.97

1
13

On Terminator 1.91-6 double click terminal title enables edition

0
9

PS1 does not need to be set. Credit for this function goes to geirha on freenode #bash

set_title() { printf '\e]2;%s\a' "$*"; }

4
  • 1
    This works for me: printf "\e]2;This is the new title\a"; I think the quotes need to be double.
    – alex.pilon
    May 1, 2013 at 14:56
  • This doesn't work for me in Ubuntu 14.04 with Terminal and also optionally installed Terminator. Quotes are fine.
    – hakre
    Nov 29, 2015 at 8:53
  • 1
    Could you provide some reference that PS1 does not need to be set as you wrote in your answer? I ask because if I do this via PS1 as described in stackoverflow.com/a/8850484/367456 it works. If I don't (like in your answer) it does not work. I would like to learn more about this PS1 not being necessary for the title.
    – hakre
    Nov 29, 2015 at 8:58
  • @hakre, I posted this in 2012, really, anything could have changed in 3 years. Mar 14, 2016 at 0:08
7

This seems to work for me. I'm using BASH on Crunchbang (Debian derived)

$ echo -en '\e]0;echo works too\a'
3

With Terminator 0.96 and GNU bash 4.2.25 the printf suggestion above worked for me, but I had to tweak it slightly to make it into a function that would just work for me in a new Terminator tab. I added this to the end of my ~/.bashrc file:

set_title() { printf "\e]2;$*\a"; }

The key was placing the \a at the end of the quoted string. Then when opening a new tab in Terminator I can use this like so:

set_title "My new tab title"

Apologies to those who already stated the essentials of this answer, but since I found that I had to make slight changes to get it to work for me, this my also benefit someone else.

2
  • 1
    FYI printf will correctly insert the first following argument in place of the '%s'. Tom Dignan solution's worked fine here on bash 4.3.8 and terminator 0.97. But yours will have known issues ('invalid character format', or missing characters in the title) if you happen to use character % in your title.
    – vaab
    Jun 3, 2014 at 7:25
  • 1
    Does not work on Ubuntu 14.04 (GNOME Terminal 3.10.2,terminator 0.97).
    – hakre
    Nov 29, 2015 at 9:57
2

Try add PROMPT_COMMAND='echo -en "\033]0; $("pwd") \a"' in your .bashrc

1

For terminator 0.98 (Ubuntu 16.04 MATE), right clicking the title enables renaming it.

1
  • 1
    For me, right click isn't working but double click works Oct 24, 2018 at 0:25
-1

Right click on terminator and choose preferences from the drop-down menu. Choose profiles tab and enable "show title bar" option. It works!!

Tip: You can actually rename each terminator window!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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