How to correctly set GNU Screen to display currently running program in hardstatus
Posted
by
johnny_bgoode
on Super User
See other posts from Super User
or by johnny_bgoode
Published on 2010-11-15T15:21:03Z
Indexed on
2011/02/19
15:27 UTC
Read the original article
Hit count: 217
In bash, to display the name of the current program in the GNU Screen hardstatus line takes only two configuration lines. First, tell screen what the end of your prompt normally looks like, and supply a default title for a window when you are sitting at in the shell:
shelltitle "$ |bash"
Next, place this escape sequence in the PS1 variable, before the characters that normally terminate the prompt '$ '
in this case: \033k\033\\
This technique works, to a point. The hardstatus window title is updated to the name of the currently running program, and then switches back to the default title shortly after execution is finished. One major problem, however, is that this escape string is not escaped itself, causing line-wrapping problems with commands longer than the initial line.
This was annoying, so I set out looking for a solution. Turns out, simply escaping the previous escape sequence corrects line wrapping: \[\033k\]\[\033\\\]
Great! My hardstatus window title still updates to the name of the currently running program, and now my longer commands wrap to the second line correctly. However, with this new escape sequence in my PS1, screen updates the window title to the actual command I am typing, not simply the name of the current program once it is executed.
I am wondering, has anyone gotten this working correctly - i.e. line wrapping and proper updating of the hardstatus window title?
© Super User or respective owner