Apple - Terminal Tab Title after SSH Session
Add a PROMPT_COMMAND
to your .bash_profile
export PROMPT_COMMAND="echo -ne '\033]0;${USER}@${HOSTNAME}\007';$PROMPT_COMMAND"
The PROMPT_COMMAND
gets executed every time the prompt is displayed.
Please note that we include the existing PROMPT_COMMAND
environment variable, such that we do not lose any existing settings (i.e. update_terminal_cwd
).
To make @s01ipsist's solution work with ZSH (new shell on macOS), you can add this to ~/.zshrc
:
export PROMPT_COMMAND="echo -ne '\033]0;${USER}@${HOST}\007';$PROMPT_COMMAND"
precmd() { eval "$PROMPT_COMMAND" }