name terminal/tabs

13

6

Is there a way to name a terminal window or even better give each tab a name. at the moment they just get the underlying process name : for example a tab running elasticsearch gets the name java

locojay

Posted 2010-12-18T03:00:40.487

Reputation: 233

http://superuser.com/q/343747/504387 – Wildcard – 2015-12-23T05:14:51.580

Answers

11

You can use @bubu 's solution, or you can right click on the tab, select "Inspect Tab", and set the title from there.

Wuffers

Posted 2010-12-18T03:00:40.487

Reputation: 16 645

5Or press Cmd-I to get the inspector. – Daniel Beck – 2010-12-18T05:16:40.157

2Shift-Command-I (Shell > Edit Title) also shows the Inspector and will ensure it selects the Info pane. – Chris Page – 2011-08-21T07:59:23.590

1As of Mac OS X Lion 10.7, Terminal's Inspector also supports setting the tab title separately from the window title. – Chris Page – 2011-08-21T08:09:22.373

14

Well.

echo -n -e "\033]0;In soviet russia, the title bar sets you\007"

will set your title to "In soviet russia, the title bar sets you"

bubu

Posted 2010-12-18T03:00:40.487

Reputation: 9 283

3Or, even shorter, you can use echo -ne instead of echo -n -e. – Wuffers – 2010-12-18T04:03:32.610

1Seems to me that the soviet russia jokes are not well received here... – bubu – 2011-06-07T01:23:41.800

5Note that "0" sets both the window and the tab title. As of Mac OS X Lion 10.7, you can set them independently, using "1" (tab title) and "2" (window title). – Chris Page – 2011-08-21T08:02:14.117

3I recommend using printf instead of echo, because it's simpler and more portable (the "-n" option is not defined in POSIX): printf '\e]0;...\a' – Chris Page – 2011-08-21T08:07:53.127

2

If you're interested in how this works, it uses an XTerm escape sequence (also known as a control sequence). A full list of sequences is available here.

– TachyonVortex – 2013-10-27T09:29:10.250

2

If you do this frequently, you can make @bubu's answer a function in your bash_profile, like so:

tab() {
    echo -ne "\033]0;$*\007"   
}

And then just call it followed by the tab name, e.g. tab Tab Title with Spaces!

Stuart Douglas

Posted 2010-12-18T03:00:40.487

Reputation: 51