Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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