Skip to content

Commit

Permalink
fix: change to check env settings after every command execution
Browse files Browse the repository at this point in the history
This will make the it correctly check variables before set title, avoiding currently issue where it was ignored
  • Loading branch information
trystan2k committed May 20, 2024
1 parent 44f5220 commit 41eadc9
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions zsh-tab-title.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,36 @@ 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
fi

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
Expand All @@ -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
Expand Down

0 comments on commit 41eadc9

Please sign in to comment.