Issue
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.
Solution
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.
Answered By - sel-fish Answer Checked By - Dawn Plyler (WPSolving Volunteer)