Skip to content

Commit 41eadc9

Browse files
committed
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
1 parent 44f5220 commit 41eadc9

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

zsh-tab-title.plugin.zsh

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,36 @@ function title {
3636
fi
3737
}
3838

39-
ZSH_THEME_TERM_TAB_TITLE_IDLE="%20<..<%~%<<" #15 char left truncated PWD
40-
41-
if [[ "$ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX" == true ]]; then
42-
ZSH_TAB_TITLE_PREFIX=""
43-
elif [[ -z "$ZSH_TAB_TITLE_PREFIX" ]]; then
44-
ZSH_TAB_TITLE_PREFIX="%n@%m:"
45-
fi
46-
47-
ZSH_THEME_TERM_TITLE_IDLE="$ZSH_TAB_TITLE_PREFIX %~ $ZSH_TAB_TITLE_SUFFIX"
48-
49-
# Runs before showing the prompt
50-
function omz_termsupport_precmd {
51-
emulate -L zsh
39+
function setTerminalTitleInIdle {
5240

5341
if [[ "$ZSH_TAB_TITLE_DISABLE_AUTO_TITLE" == true ]]; then
5442
return
5543
fi
5644

5745
if [[ "$ZSH_TAB_TITLE_ONLY_FOLDER" == true ]]; then
5846
ZSH_THEME_TERM_TAB_TITLE_IDLE=${PWD##*/}
47+
else
48+
ZSH_THEME_TERM_TAB_TITLE_IDLE="%20<..<%~%<<" #15 char left truncated PWD
49+
fi
50+
51+
if [[ "$ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX" == true ]]; then
52+
ZSH_TAB_TITLE_PREFIX=""
53+
elif [[ -z "$ZSH_TAB_TITLE_PREFIX" ]]; then
54+
ZSH_TAB_TITLE_PREFIX="%n@%m:"
5955
fi
6056

57+
ZSH_THEME_TERM_TITLE_IDLE="$ZSH_TAB_TITLE_PREFIX %~ $ZSH_TAB_TITLE_SUFFIX"
58+
6159
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
6260
}
6361

62+
# Runs before showing the prompt
63+
function omz_termsupport_precmd {
64+
emulate -L zsh
65+
66+
setTerminalTitleInIdle
67+
}
68+
6469
# Runs before executing the command
6570
function omz_termsupport_preexec {
6671
emulate -L zsh
@@ -87,7 +92,7 @@ function omz_termsupport_preexec {
8792
}
8893

8994
# Execute the first time, so it show correctly on terminal load
90-
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
95+
setTerminalTitleInIdle
9196

9297
autoload -U add-zsh-hook
9398
add-zsh-hook precmd omz_termsupport_precmd

0 commit comments

Comments
 (0)