I frequently use ssh within screen to connect to a set of machines. It would be ideal to have the caption line show information about the server that I am ssh'd into (eg machinename, uptime and info from vmstat).

I noticed that the backtick screen command only seems to run where screen is run, it doesn't execute on the remote machine. Is there an easy way to get backtick to run the command on whatever machine is currently ssh'd?

1 Answer 1


Screen recognizes a few extra control sequences that the terminal inside a window can send to affect Screen. Of particular interest to you will probably be the \ek and \e\ sequences. Anything in between those two will be used by Screen as the window title. You can then put the window title in your caption line.


Give this a try:

PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007\ek${USER}@${HOSTNAME}: ${PWD/$HOME/~}\e\\"'

I use that as my prompt on remote systems. It automatically sets the window title to be user@name: path. The escape sequence for Screen is at the end of that command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .