[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window Titling

From: Dan Mahoney (Gushi)
Subject: Re: Window Titling
Date: Wed, 1 Jul 2020 14:47:02 -0700 (PDT)
User-agent: Alpine 2.21.99999 (BSF 352 2019-06-22)

On Wed, 1 Jul 2020, Dave Wood wrote:

On 01/07/20 00:24,
Dan Mahoney (Gushi) <> put forth the proposition:
On Tue, 30 Jun 2020, Dan Mahoney (Gushi) wrote:

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" "\!#:$"
(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?

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

You can find the relevant section with:

man screen | less -p "THE VIRTUAL TERMINAL"


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:

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 Mahoney--------
Techie,  Sysadmin,  WebGeek
Gushi on efnet/undernet IRC

reply via email to

[Prev in Thread] Current Thread [Next in Thread]