#358965 bash: Please support setting terminal title for screen

Package:
bash
Source:
bash
Description:
GNU Bourne Again SHell
Submitter:
Christopher Zimmermann
Date:
2024-05-15 11:27:11 UTC
Severity:
wishlist
Tags:
#358965#5
Date:
2006-03-25 15:13:09 UTC
From:
To:
Hi,
it would be nice to be able to use the feature of screen described in
info screen Window Naming Dynamic.
Bash could easily support this feature by adding three lines to
/etc/skel/.bashrc:

 # If this is an xterm set the title to user@host:dir
 case "$TERM" in
 xterm*|rxvt*)
     PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
     ;;
+screen*)
+    PROMPT_COMMAND='echo -ne "\033k\033\134"'
+    ;;
 *)
     ;;
 esac

Regards,
Christopher

#358965#10
Date:
2006-04-23 14:19:34 UTC
From:
To:
Christopher Zimmermann writes:

I'm unable to see this working. How is this supposed to work?

#358965#15
Date:
2008-10-02 08:23:59 UTC
From:
To:
You probably should use:

screen*)
    PROMPT_COMMAND='echo -n -e "\033k\033\0134"'
    ;;

See https://savannah.gnu.org/bugs/?24133#comment0.

Or

screen*)
    PROMPT_COMMAND='echo -ne "\033k\033\\"'
    ;;

See https://bugs.launchpad.net/ubuntu/+bug/188938.

AFAIK the screen PROMPT_COMMAND case in .bashrc is dependent upon the following
being in your .screenrc:

# Set the title to the name of the running program
shelltitle "$ |bash"

See the TITLES (naming windows) section in the screen man page.

#358965#18
Date:
2013-07-06 22:47:59 UTC
From:
To:
This request still applies to current versions of bash.
/etc/skel/.bashrc has changed, though; it no longer uses PROMPT_COMMAND.
I've attached a patch to debian/skel.bashrc in the source package, which
addresses this request.

Note that the number of backslashes in the prompt is quite intentional
(screen's control sequence ends in \\, which needs doubling to escape it
within a double-quoted string), as is the ;& fall-through at the end of
the screen case (the xterm control sequence also sets screen's
hardstatus, which sets the title of the xterm or similar that screen
runs in).

- Josh Triplett

#358965#25
Date:
2014-05-04 12:33:23 UTC
From:
To:
I just spent half an hour figuring out how to get window titles to
reflect my session in byobu.. and I find the exact patch required is
already here (thanks Josh).

I guess this is just a +1 for patching skel.bashrc so that ssh-ing into
machines via byobu does The Right Thing to your terminal emulator's
window title automatically.

#358965#32
Date:
2024-05-15 11:24:45 UTC
From:
To:

The screen manpage explains this, and recommends a slightly different
formulation for escaping  --- might want to use that for consistency:


PROMPT_COMMAND='printf "\033k\033\134"'