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
Christopher Zimmermann writes: I'm unable to see this working. How is this supposed to work?
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.
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
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.
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"'