From 6e532a48e46ae56daec18255512dd8d0597f4aa6 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Tue, 7 Dec 2021 06:56:30 -0800 Subject: [PATCH] fix: prevent execution of the command in title. https://github.com/trystan2k/zsh-tab-title/pull/20#issuecomment-987573715 --- zsh-tab-title.plugin.zsh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/zsh-tab-title.plugin.zsh b/zsh-tab-title.plugin.zsh index 4995c8d..a56d088 100644 --- a/zsh-tab-title.plugin.zsh +++ b/zsh-tab-title.plugin.zsh @@ -2,7 +2,7 @@ # Set terminal window and tab/icon title # -# usage: title short_tab_title [long_window_title] +# usage: title short_tab_title long_window_title # # See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 # Fully supports screen, hyper, iterm, and probably most modern xterm and rxvt @@ -13,25 +13,24 @@ function title { [[ "$EMACS" == *term* ]] && return - # if $2 is unset use $1 as default - # if it is set and empty, leave it as is - : "${2=$1}" + tabTitle="\$1" + termTitle="\$2" if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then - print -Pn "\e]2;$2:q\a" # set window name - print -Pn "\e]1;$1:q\a" # set tab name + print -Pn "\e]2;$termTitle:q\a" # set window name + print -Pn "\e]1;$tabTitle:q\a" # set tab name elif [[ "$TERM_PROGRAM" == "Hyper" ]]; then - print -Pn "\e]1;$2:q\a" # set tab name - print -Pn "\e]2;$1:q\a" # set window name + print -Pn "\e]1;$termTitle:q\a" # set tab name + print -Pn "\e]2;$tabTitle:q\a" # set window name else case "$TERM" in cygwin|xterm*|putty*|rxvt*|ansi|${~ZSH_TAB_TITLE_ADDITIONAL_TERMS}) - print -Pn "\e]2;$2:q\a" # set window name - print -Pn "\e]1;$1:q\a" # set tab name + print -Pn "\e]2;$termTitle:q\a" # set window name + print -Pn "\e]1;$tabTitle:q\a" # set tab name ;; - + screen*|tmux*) - print -Pn "\ek$1:q\e\\" # set screen hardstatus + print -Pn "\ek$tabTitle:q\e\\" # set screen hardstatus ;; esac fi