Bash – How to stop screen from clobbering the titles

bashgnu-screenterminal

I am using bash and GNU screen on centos7. I notice that if I ssh to another server, change the title (via ctrl+a+A), and log out of the server that my new title gets overwritten by USER@HOST:~. How can I stop it from doing this?

I've looked into dynamic titles and determined that's what's at play, but I'm unsure of how to disable that feature…

Best Answer

As documented in the man page, screen looks for a null title-escape-sequence. bash sends this sequence via the PROMPT_COMMAND environment variable (for example, mine defaults to printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}".

To disable this feature for a particular window, I just run unset PROMPT_COMMAND from that window. Of course, one could just add this to their ~/.bashrc or to a specific environment file to make it more persistent.

Related Question