I want to set the terminal tab name from the command line. I am using this command to update the name echo -en "\033]0; New Name \007". Here is what my terminal now looks like.

New Name with other stuff

When I use the Inspector through GUI, I have the ability to set the terminal name and the tab name. When I set it via the GUI, here is what I see.

New Name alone

As you can see there isn't any dashes - or text on the tab. How do I do this from the command line?

  • I don’t see a pure duplicate, but maybe check this or that. Also, what precisely do you want to show since you passed a string without dashes I’m not sure where you want the dashes to show.
    – bmike
    Commented Jul 17, 2019 at 17:23
  • In terminal.app go to preferences > profiles. You can set the options there. Commented Jul 17, 2019 at 19:01
  • 1
    I am trying to do this all programmatically. I don't want to use the GUI.
    – jhamm
    Commented Jul 18, 2019 at 2:27
  • I just want to add a title to the tab and nothing else. Then I can see exactly what I am doing on that tab. The dashes are other stuff are just noise and get in the way.
    – jhamm
    Commented Jul 18, 2019 at 2:28

1 Answer 1



You can do this with something like echo -en "\033]1; New Name \007" or printf '\e]1;%s\a' 'New Name'. You may have to fiddle with your profile's window/tab title settings, though.


This behavior is a little complex and not well explained I guess.

Title types

First, you can set two types of title. Terminal.app calls these the tab title (aka the icon name/title) and the window title (as you can see in the inspector).

The XTERM escape sequences for setting these are:

  • ESC]0;stringBEL -- Set icon name and window title to string
  • ESC]1;stringBEL -- Set icon name to string
  • ESC]2;stringBEL -- Set window title to string

I'm not sure how common this behavior is across terminal emulators, but Terminal.app doesn't actually do what 0 describes here. It sets the window title, and clears the tab title (probably because, as I'll show later, Terminal will pick up the window title if the tab title is unset).

The reason you see different behavior is because your command is setting the window title, but in the inspector you're setting the tab title.

Terminal.app title features

The dashes in the title are just separators that Terminal.app is using whenever it's combining multiple pieces of information in your title. (Pieces here include the profile "tab" and "window" Title options, as well as the window and tab titles themselves)

If you set both a window title and a tab title, it'll use them both. With multiple tabs, it'll separate them:titles with tabs

If the tab is in it's own window, though, it'll combine them and show the separator (unless you use the view menu to force it to show the tab bar even with a single tab):titles without tabs

You can still get it to show a single title, but you'll have to use only the window or the tab title (the window title will pick up the tab title if no windows title is set):windows with tab & window titles

The inverse (tabs can pick up a window title if no tab title is set) is also roughly true, but the behavior can be a little surprising. Here are the same tabs in two windows along with the settings panel (to show that it's set to show the TTY name, but not to show items when there's a custom title): tabs with tab & window titles The top window is picking up the default "Terminal" title because the current tab doesn't have a window title. Its tab doesn't show the TTY, because it has a custom tab title. The bottom window shows that the tab will pick up the window title if it doesn't have a tab title. The TTY shows up in the tab title because it doesn't have a custom tab title--just a custom window title.

  • 1
    If you're using bash, watch out for how your PS1 is set. I somehow have $debian_chroot embedded in PS1 and use PS1 to reset my xterm title every time my bash prompt is shown - completely screwed me up. Commented Mar 8, 2022 at 2:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .