13

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

1

3 Answers 3

12

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

4
  • 6
    Or press Cmd-I to get the inspector.
    – Daniel Beck
    Dec 18, 2010 at 5:16
  • 2
    Shift-Command-I (Shell > Edit Title) also shows the Inspector and will ensure it selects the Info pane.
    – Chris Page
    Aug 21, 2011 at 7:59
  • 1
    As of Mac OS X Lion 10.7, Terminal's Inspector also supports setting the tab title separately from the window title.
    – Chris Page
    Aug 21, 2011 at 8:09
  • I came across this post in 2021, I'm on macOS Catalina - @DanielBeck solution is what was most helpful for me. When you do Cmd-I you get the inspector window, and in there is a field called "Tab Title."
    – Stpete111
    May 13, 2021 at 13:50
16

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"

5
  • 3
    Or, even shorter, you can use echo -ne instead of echo -n -e.
    – Wuffers
    Dec 18, 2010 at 4:03
  • 1
    Seems to me that the soviet russia jokes are not well received here...
    – bubu
    Jun 7, 2011 at 1:23
  • 5
    Note 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
    Aug 21, 2011 at 8:02
  • 3
    I 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
    Aug 21, 2011 at 8:07
  • 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. Oct 27, 2013 at 9:29
4

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!

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.