commit:     9ff9f8199ccf9d55fb1cf066cbbc791101894ab0
Author:     Sven Wegener <swegener <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 16:47:32 2024 +0000
Commit:     Sven Wegener <swegener <AT> gentoo <DOT> org>
CommitDate: Sat Jun 22 20:26:45 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9ff9f819

app-shells/bash: do not update internal window title of screen and tmux

The k escape sequence changes the internal window title of screen and
tmux, which is an alias given to the window by the user. The alias can
be used to reference the window in internal commands, e.g. by using
"select <alias>" in screen or "select-window -t <alias>" in tmux to
switch to a window by name, and should not be updated by commands
running inside of screen and tmux.

Closes: https://bugs.gentoo.org/934732
Signed-off-by: Sven Wegener <swegener <AT> gentoo.org>

 .../bash/files/bashrc.d/10-gentoo-title.bash       | 32 ++++++----------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash 
b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
index 0246d4fa36f0..003e364ff072 100644
--- a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
@@ -16,8 +16,8 @@ genfun_set_win_title() {
 
        # Sets the window title with the Set Text Parameters sequence. For
        # screen, the sequence defines the hardstatus (%h) and for tmux, the
-       # window_name (#W). For graphical terminal emulators, it is normal for
-       # the title bar be affected.
+       # pane_title (#T). For graphical terminal emulators, it is normal for
+       # the title bar to be affected.
        genfun_set_win_title() {
                genfun_sanitise_cwd
                printf '\033]2;%s@%s - %s\007' "${USER}" "${HOSTNAME%%.*}" 
"${_cwd}"
@@ -26,27 +26,13 @@ genfun_set_win_title() {
        genfun_set_win_title
 }
 
-# Set window title with the Title Definition String sequence. For screen, the
-# sequence defines the window title (%t) and for tmux, the pane_title (#T).
-# For tmux to be affected requires that its allow-rename option be enabled.
-# https://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html
-case ${TERM} in
-       screen*|tmux*)
-               genfun_set_pane_title() {
-                       printf '\033k%s\033\\' "${HOSTNAME%%.*}"
-               }
-               PROMPT_COMMAND+=('genfun_set_pane_title')
-               ;;
-       *)
-               # If the TTY is that of sshd(8) then proceed no further. Alas,
-               # there exist many operating environments in which the window
-               # title would otherwise not be restored upon ssh(1) exiting.
-               # Users wishing to coerce the historical behaviour have the
-               # option of setting PROMPT_COMMAND=(genfun_set_win_title).
-               if [[ ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; then
-                       return
-               fi
-esac
+# If the TTY is that of sshd(8) then proceed no further. Alas, there exist many
+# operating environments in which the window title would otherwise not be
+# restored upon ssh(1) exiting. Users wishing to coerce the historical
+# behaviour have the option of setting PROMPT_COMMAND=(genfun_set_win_title).
+if [[ ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; then
+       return
+fi
 
 # Determine whether the terminal can handle the Set Text Parameters sequence.
 # The only terminals permitted here are those for which there is empirical

Reply via email to