Search code examples
unixterminalzshoh-my-zshhyperterm

What does terminal / hyperterm display in the tab title? Is it possible to customize this?


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


Solution

  • 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.