Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to improve the aspect of GNU Screen using the screenrc file, I tuned colors, status line, caption and the list of the loaded windows.

The only thing I'm not able to achieve is getting the caption with the current executed command as in the below picture, note the vim caption in the right pane:

enter image description here

What I currently have is this, and what I would like to obtain is having captions (and if possible also hardstatus line) with |0 less| 1 man instead of the current |0 bash| 1 bash.

How can I do this?

Update: Until now the only working solution I found is in this post but it doesn't print what I need...

However that is the only working dynamic title I found until now.

PROMPT_COMMAND='echo -ne "\033k\033\134\033k${HOSTNAME}[`basename ${PWD}`]\033\134"'`

in .bashrc and shelltitle '] |bash' in .screenrc. The title is updated with the hostname and the basename of the working directory, but the prompt is completely wrong (it also has a leading space):

134134fabio@host10:~$
share|improve this question

migrated from serverfault.com Feb 10 '11 at 23:59

This question came from our site for professional system and network administrators.

    
checkout the updates on the answer –  Torian Feb 12 '11 at 2:03

2 Answers 2

In your .bashrc file set your PROMPT_COMMAND like this:

UPDATE:

case "$TERM" in
    screen*) PROMPT_COMMAND='echo -ne "\033k\033\0134"'
esac

UPDATE: seems to be a bug with echo built into bash. Solution should be either use of /bin/echo or \0134. Try:

$ echo -e "\134 = \0134"
\134 = \
$ /bin/echo -e "\134 = \0134"
\ = \

This is the escape sequence that screen needs to identify which command is being run, and replace the title of your current window.

Then, on your .screenrc file, make sure the following lines exist:

shelltitle '> |something:'
hardstatus alwayslastline

The pattern search|name tells screen to search your end-of-prompt for some string (in this case, '> '). The name part, specifies the default shell name for the window. So, when you have nothing but the shell running, you'll see something like:

$ something:

But when you run top:

$ something:top
share|improve this answer
    
Almost... Your hint for \0134 or /bin/echo works with my above example, so I can have the caption updated with the string between two escape sequences without having my prompt messed. But I can't still make your example working. My prompt under screen is ${debian_chroot:+($debian_chroot)}\u@\h:\w\$ so I'm using shelltitle '$ |bash', is that right? –  Fabio Feb 12 '11 at 14:07
    
thanks, I'm having it work without the hardstatus ... line in .screenrc, I'm using caption always ..., not a screen guru though. –  ryenus Jul 4 at 1:41

As an alternative, you could use tmux instead of screen. Tmux will automatically set the current window's title.

share|improve this answer

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.