From 41eadc9f9db538df624381a30db0abd7b41c65fd Mon Sep 17 00:00:00 2001 From: Thiago Mendonca Date: Sun, 22 Oct 2023 13:39:56 +0200 Subject: [PATCH] fix: change to check env settings after every command execution This will make the it correctly check variables before set title, avoiding currently issue where it was ignored --- zsh-tab-title.plugin.zsh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/zsh-tab-title.plugin.zsh b/zsh-tab-title.plugin.zsh index a56d088..b44d599 100644 --- a/zsh-tab-title.plugin.zsh +++ b/zsh-tab-title.plugin.zsh @@ -36,19 +36,7 @@ function title { fi } -ZSH_THEME_TERM_TAB_TITLE_IDLE="%20<..<%~%<<" #15 char left truncated PWD - -if [[ "$ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX" == true ]]; then - ZSH_TAB_TITLE_PREFIX="" -elif [[ -z "$ZSH_TAB_TITLE_PREFIX" ]]; then - ZSH_TAB_TITLE_PREFIX="%n@%m:" -fi - -ZSH_THEME_TERM_TITLE_IDLE="$ZSH_TAB_TITLE_PREFIX %~ $ZSH_TAB_TITLE_SUFFIX" - -# Runs before showing the prompt -function omz_termsupport_precmd { - emulate -L zsh +function setTerminalTitleInIdle { if [[ "$ZSH_TAB_TITLE_DISABLE_AUTO_TITLE" == true ]]; then return @@ -56,11 +44,28 @@ function omz_termsupport_precmd { if [[ "$ZSH_TAB_TITLE_ONLY_FOLDER" == true ]]; then ZSH_THEME_TERM_TAB_TITLE_IDLE=${PWD##*/} + else + ZSH_THEME_TERM_TAB_TITLE_IDLE="%20<..<%~%<<" #15 char left truncated PWD + fi + + if [[ "$ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX" == true ]]; then + ZSH_TAB_TITLE_PREFIX="" + elif [[ -z "$ZSH_TAB_TITLE_PREFIX" ]]; then + ZSH_TAB_TITLE_PREFIX="%n@%m:" fi + ZSH_THEME_TERM_TITLE_IDLE="$ZSH_TAB_TITLE_PREFIX %~ $ZSH_TAB_TITLE_SUFFIX" + title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE" } +# Runs before showing the prompt +function omz_termsupport_precmd { + emulate -L zsh + + setTerminalTitleInIdle +} + # Runs before executing the command function omz_termsupport_preexec { emulate -L zsh @@ -87,7 +92,7 @@ function omz_termsupport_preexec { } # Execute the first time, so it show correctly on terminal load -title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE" +setTerminalTitleInIdle autoload -U add-zsh-hook add-zsh-hook precmd omz_termsupport_precmd