On 01/07/20 00:24, Dan Mahoney (Gushi) <d...@prime.gushi.org> put forth the proposition: > On Tue, 30 Jun 2020, Dan Mahoney (Gushi) wrote: > > All, > > > > I'm using the \033k hack to auto-title my windows in the listing brought > > up by ctrl-a " (and also in the statusline). > > > > Is there a way to embed color information into this screen (for example, > > I might want any window with a root shell to have a red title). > Instead, I directly print the escape sequences IN my .bashrc/cshrc to give > me useful window titles like where I'm sshing from/to, etc. (This seems > important given the above context), rather than having screen try to parse > the output of my shell and guess about what the title should be. > As an example, in cshrc I do: > alias postcmd 'printf "\033%s%s %s %s\033\\" "k" "\!#:0" "\!#:$" > "[$HOST]"' > (This gives me a title like ssh hostname, where the command could be ssh -v > -v -t hostname) > The screen manual should certainly make mention of this method, and include > examples for bash and the like. I'm willing to contribute text and > examples. Is this a better question for screen-dev? > -Dan
>From the section THE VIRTUAL TERMINAL in the list of control sequences in the screen manual: ESC k A.k.a. Definition String Which is what you're doing with \033k (\033 is escape). You can shorten it to \ek in printf and the \033\\ is: ESC \ (A) String Terminator Which can also be shortened to \e\. A second \ is needed to escape the closing quote. So the quick way to change the title with a string would be: printf "\ek%s\e\\" "title string" Unfortunately, there isn't a way to change the colour, at least not up to the version that I have (4.6.2), however you can change the bell and monitor colours using the `rendition' definitions, but of course it would only change colour when a bell or message is received. Colours in the hardstatus can be set using \005{} in a printf statement, with the screen colour definitions inside the braces, e.g.: printf "%b" "\005{ck}Some Status Text" Or similar, which would make black text (k) on a cyan background (c). You need the %b rather than %s for the control code to be printed properly. You can find the relevant section with: man screen | less -p "THE VIRTUAL TERMINAL" Hope this helps, -- Dave