1

I'm confused what data is being shown in my terminal tabs. The first part, epzio is obviously my username. But the second part, @C02S60BBG8WP, I have no idea.

Note: I use zsh combined with oh-my-zsh for my shell.

Is it possible to customize what is shown in the tab titles? I'd like to remove the epzio@C02S60BBG8WP part altogether and just display the current working directory.

Also, why do my tab titles turn blue for no apparent reason? I thought this was only supposed to happen when you had a specific process such as node running. As you can see in the screenshot below, the tic-tac-toe tab has turned blue even though nothing is happening in that tab.

Update: It seems that the solution might involve making changes to ~/.oh-my-zsh/lib/termsupport.zsh, but I'm not sure if these would get overridden when oh-my-zsh updates itself.

enter image description here

J. Munson
  • 2,275
  • 2
  • 17
  • 22

1 Answers1

7

C02S60BBG8WP is probably your hostname; check by typing hostname.

You can change the terminal title by printing an escape sequence like this:

echo -en "\033]0;New terminal title\a"

So this should change the title to your current working directory, $PWD, substituted by a single ~ if you're in $HOME:

echo -en "\033]0;${PWD/#$HOME/~}\007"

If that doesn't work, it's probably being overridden immediately afterwards by a command that is automatically invoked by your shell. In bash, this would be PROMPT_COMMAND which on my system looks like this:

$ echo $PROMPT_COMMAND 
__vte_prompt_command; printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"

The zsh equivalent seems to be to define a precmd hook:

precmd() { echo -en "\033]0;${PWD/#$HOME/~}\007" }

To make that permanent, you can just put it your .zshrc.

Thomas
  • 174,939
  • 50
  • 355
  • 478
  • 2
    Thank you Thomas. `precmd() { echo -n -e "\033]0;$(basename "$PWD")\007" }` is what I eventually settled on, and I placed it at the bottom of `.zshrc`. The only additional thing I needed to do, since I'm using oh-my-zsh, was to uncomment `DISABLE_AUTO_TITLE="true"` – J. Munson Oct 04 '19 at 19:53
  • If you're using Oh-My-Zsh, don't forget to add the following option to your .zshrc file DISABLE_AUTO_TITLE="true" – Oli Jun 21 '22 at 15:57