Re: Window Titling

"Dan Mahoney (Gushi)" <[email protected]> Wed, 1 Jul 2020 14:47:02 -0700 (PDT)
Newsgroups gmane.comp.gnu.screen.user
Message-ID <[email protected]>
On Wed, 1 Jul 2020, Dave Wood wrote:

> On 01/07/20 00:24,
> Dan Mahoney (Gushi) <[email protected]> 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"

Thanks,

My point is, effectively, there are two types of "dynamic" titles.  One 
where the shell sets it directly, and one where screen "guesses" at it.

the screen manual section on Dyanmic Titles:

https://www.gnu.org/software/screen/manual/screen.html#Dynamic-Titles

Doesn't point at the info above, only talking about the second method.

Most recent "friendly" distros like Ubuntu seem to do the former (for use 
with other tabbed terminal apps, and screen also reaps the benefits).

-Dan

-- 

--------Dan Mahoney--------
Techie,  Sysadmin,  WebGeek
Gushi on efnet/undernet IRC
FB:  fb.com/DanielMahoneyIV
LI:   linkedin.com/in/gushi
Site:  http://www.gushi.org
---------------------------