I like to name my tabs when I'm using Terminal so I can keep track of what's inside of them. I do this using the inspector.

Unfortunately, whenever I ssh into a machine, my tabs get renamed. Is there any way to prevent this from happening? Perhaps there's some kind of shell script I could run in my bash profile to prevent this?


Using iTerm2 you actually have an option for that: Just uncheck Preferences->Profiles->Your Profile->Terminal->Terminal may set tab/window title. Fancy description

  • It's been moved to PreferencesProfiles[your profile]GeneralApplications in terminal may change the title Apr 8 '21 at 22:51

You can setup a new or change an existing profile in the settings of Terminal.

Choose your new or the existing profile and click on Window and uncheck all the options at the Title segment.

Edit: For shells which change the promt via shell variable PS1 you have to deal with it as long you connected the the given host without changing the promt on the remote session. To change this in a bash you will find something like

# If this is an xterm set the title to user@host:dir
case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\H: \w\a\]$PS1"

in your .bashrc.

If you comment out this block your local title will not change but your promt may be looking awful.

Maybe there are other lines where the shell variable PS1 is set. Maybe you have to comment out these too.

Edit2: Also you have the ability to give the local PS1 to the remote session. To do so you invoke ssh with

ssh -o SendEnv=PS1 user@host

But for this you have to edit the sshd_config. There you have to add PS1 to the list of AcceptEnv. This requires root access. Maybe not really a solution.


If you're looking to never rename your window, no matter where you connect from, you might want to change the setting in the remote machine. The thing that renames the window is the escape sequence \033k, as described here

Bash users will probably want to echo the escape sequence in the PROMPT_COMMAND:

PROMPT_COMMAND='printf "\033k\033\134"'

In this case, if you change the PROMPT_COMMAND environment variable in your remote shell, it will stop renaming the window.

You must log in to answer this question.

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