On my local machine, window titles within screen update nicely to the pwd. I have

shelltitle '% |bash'

in my .screenrc. Yet when I ssh to another host, the window title remains as the pwd from where I ran the ssh command, rather than updating to be the pwd within my ssh session.

How can I make my screen window title relative to my ssh session?


You can change the window title of the current screen session with echo -en "\033kNEW TITLE\033\134". On your local machine you have probably some code in your ~/.bashrc oder in some global config file (the location can depend on OS flavor) which changes the title accordingly, e.g. in your prompt setting; try echo $PS1.

So, you have to modify the remote ~/.bashrc, too. A good starting point can be

PS1='\033k\u@\h: \w\033\134\u@\h:\w > '

which will display a prompt like user@machine:~ > and sets the screen title to user@machine:~.

Please be aware, that this will not change the title of your terminal window. The command for that is echo -ne "\033]0;SOMETHING\007".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.