2

I use iTerm2 as my terminal on OS X. When I SSH into a machine, I like to name my tabs by going into the session preferences (cmd + i). Whenever I run another bash command after setting this preference, the tab title goes back to the default that it was when I first SSHd in.

Browsing around for an answer, I found this answer by Chad that is working for me:

export PROMPT_COMMAND=''
echo -e "\033];MY_NEW_TITLE\007"

I don't really understand the PROMPT_COMMAND line, though I tried looking it up.

Can someone explain this in simple terms?

Same question for the 2nd line, as I don't even know how to begin researching that.

Community
  • 1
  • 1
smilebomb
  • 5,123
  • 8
  • 49
  • 81

3 Answers3

1

You can read iTerm2 escape code .
I didn't read the related iTerm2 code thoroughly, but it seems like an interface to manipulate iTerm2.
I guess iTerm2 does this magic by parse the output of screen if the contents fit special format(start by "\033]" and so on), iTerm2 will consider that's the information mean to sent to itself.

sel-fish
  • 4,308
  • 2
  • 20
  • 39
  • Ah, I didn't know iTerm2 had proprietary escape codes; that's the piece I was missing. Thank you. – smilebomb Apr 21 '16 at 13:24
  • Upon further research, the escaping of those octal representations of ascii are not proprietary iTerm2 escape codes. They are just plain bash escape codes. – smilebomb Apr 21 '16 at 18:19
  • 1
    They are actually terminal escape codes; they are unrelated to Bash. Many are inherited all the way back from VT52/VT100 terminals but this one in particular was introduced in `xterm` (hardware terminals obviously did not have a window title). – tripleee Apr 22 '16 at 08:09
1

To keep the original tab:

Go to Iterm's Preferences > Profiles > Terminal

Uncheck "Terminal may set tab/window title"

Now you can name your tab, ssh into a server, exit and still keep the original tab name.

Credit to: https://groups.google.com/forum/#!topic/iterm2-discuss/czV-sv4ykzI

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
alakin_11
  • 689
  • 6
  • 12
0

I used tabset node plugin. It works like a charm, and also color codes each tab, and has multiple options to color code, add a badge and even bring up a color picker to choose.

Krishna Vedula
  • 1,643
  • 1
  • 27
  • 31