2

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

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.

http://www.gnu.org/software/screen/manual/screen.html#index-control-sequences-107

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.

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.