From dcb0a69bcbdcb35d0d688c560c8d515a049deadb Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Mon, 23 Dec 2024 14:06:06 +0100 Subject: [PATCH 1/2] zshrc: introduce inside_multiplexer function Can be used to unify screen/tmux detection in one place. --- etc/zsh/zshrc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index f26af6c..0ef0a3e 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2368,6 +2368,14 @@ setopt transient_rprompt # Terminal-title wizardry +function inside_multiplexer () { + case "$TERM" in + screen|screen-*) return 0 ;; + tmux|tmux-*) return 0 ;; + esac + return 1 +} + function ESC_print () { info_print $'\ek' $'\e\\' "$@" } From f5eba885e89c2f148b373e1a0555ae2152a60d1f Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Mon, 23 Dec 2024 14:08:24 +0100 Subject: [PATCH 2/2] zshrc: use inside_multiplexer --- etc/zsh/zshrc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 0ef0a3e..0e7dd5f 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2405,7 +2405,7 @@ function grml_reset_screen_title () { } function grml_vcs_to_screen_title () { - if [[ $TERM == screen* ]] ; then + if inside_multiplexer ; then if [[ -n ${vcs_info_msg_1_} ]] ; then ESC_print ${vcs_info_msg_1_} else @@ -2415,9 +2415,9 @@ function grml_vcs_to_screen_title () { } function grml_cmd_to_screen_title () { - # get the name of the currently running program to set screen window title - # if running in a screen. - if [[ "$TERM" == screen* ]] ; then + # get the name of the currently running program to set multiplexer window title + # if running in a terminal multiplexer (screen/tmux). + if inside_multiplexer ; then local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}" ESC_print ${CMD} fi @@ -2581,7 +2581,8 @@ the zsh yet. :) "NOCOR=1 zsh" => deactivate automatic correction "NOMENU=1 zsh" => do not use auto menu completion (note: use ctrl-d for completion instead!) - "NOPRECMD=1 zsh" => disable the precmd + preexec commands (set GNU screen title) + "NOPRECMD=1 zsh" => disable the precmd + preexec commands + (would set GNU screen/tmux title) "NOTITLE=1 zsh" => disable setting the title of xterms without disabling preexec() and precmd() completely "GRML_DISPLAY_BATTERY=1 zsh"