Comment 17 for bug 338722

Revision history for this message
Bob Will (bob-will2001) wrote :

I do not use byobu, but screen does work with window titles, even with hardstatus alwayslastline, if you surround with a DCS escape block.

Note that "hardstatus alwayslastline" intercepting the normal set title escape block is its intended purpose. The hardstatus in that case is intended to be used as a replacement title (instead of using the Window's real title).

Tthere is already a way to send escape sequences directly to the xterm, passing through screen. It was not easy to find, but from the screen code (src/ansi.c) I think its been there since 2005. I have it working in xterm, Gnome Terminal, and putty. I found a note in mintty source indicating it does not work there simply because they don't handle DCS (unless it was fixed recently).

See the documentation for screen at http://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html

    ESC P (A) Device Control String
                      Outputs a string directly to the host terminal without interpretation.

The ANSI DCS (Device Control String) is an escape code that is used to send directly to a terminal (I think that was its original purpose from many years ago). Such a string is terminated with an ST escape code (String Terminator).

Wrap the string to set the terminal's window title inside a DCS..ST block, and it goes through screen and updates correctly.

This works with hardstatus alwayslastline set.

DCS = \033P
ST = \033\\

Example - to update the window title with the current working directory, use the line below. If you are in screen, even with "hardstatus alwayslastline", and ssh into a remote host and run this line, the window's title will be updated with the current dir on the remote machine.

echo -ne "\033P\033]0;${PWD/$HOME/~}\007\033\\"

Just in case I'm wrong about the screen source changes and there's something new:

I am running the latest from screen-session git, which in turn is using almost the latest from screen git (with some changes specific to screen-session). But the log messages are dated from 2005 screen (you can see the changes made to that commit regarding DCS handling if you clone the screen git repo and use the command below).
    git clone git://git.savannah.gnu.org/screen.git
    git difftool e6618a14^! src/ansi.c