Setting Title for Tabs in Terminator (Console Application) in Ubuntu
Asked Answered
P

10

43

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.

Preparedness answered 17/3, 2011 at 18:5 Comment(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.Preparedness
Even I want this feature. Any luck finding solution for this ?Coefficient
B
39
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.

Biblioclast answered 13/1, 2012 at 12:20 Comment(4)
excellent! Just visited this today :D Terminator on ubuntu works.Brittle
How comes it works if I paste this directly in a terminal, but not not in a bash script ?Armada
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.98Filicide
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.Etoile
L
31

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]

Lifeline answered 5/3, 2017 at 13:10 Comment(1)
How to run this from the shell on tab already opened! That would be great.Peer
R
19

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

Roney answered 14/5, 2016 at 8:12 Comment(1)
This approach is only useful is you will use the terminal locally. If you need to SSH the correct approach was indicated at https://mcmap.net/q/378334/-setting-title-for-tabs-in-terminator-console-application-in-ubuntu.Floreneflorentia
P
15

On Terminator 1.91-6 double click terminal title enables edition

Pluri answered 20/5, 2019 at 13:43 Comment(0)
T
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' "$*"; }

Trista answered 8/12, 2012 at 0:57 Comment(4)
This works for me: printf "\e]2;This is the new title\a"; I think the quotes need to be double.Intermarry
This doesn't work for me in Ubuntu 14.04 with Terminal and also optionally installed Terminator. Quotes are fine.Shift
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 https://mcmap.net/q/378334/-setting-title-for-tabs-in-terminator-console-application-in-ubuntu 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.Shift
@hakre, I posted this in 2012, really, anything could have changed in 3 years.Trista
S
7

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

$ echo -en '\e]0;echo works too\a'
Samuella answered 21/3, 2014 at 1:30 Comment(0)
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.

Aristippus answered 17/4, 2014 at 6:59 Comment(2)
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.Reprehensible
Does not work on Ubuntu 14.04 (GNOME Terminal 3.10.2,terminator 0.97).Shift
C
2

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

Clinandrium answered 2/10, 2017 at 14:31 Comment(0)
B
1

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

Bolshevist answered 24/6, 2018 at 6:8 Comment(1)
For me, right click isn't working but double click worksCheroot
O
-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!!

Olivarez answered 31/3, 2017 at 16:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.