Skip to content

Commit

Permalink
Show warning when Oh My Zsh themes are enabled (#426)
Browse files Browse the repository at this point in the history
The logic here is that if we unset ZSH_THEME during Pure init, we guard
against this scenario:

```
ZSH_THEME=sometheme
prompt pure
source $ZSH/oh-my-zsh.zsh
```

Also, by unsetting ZSH_THEME we can detect the following scenario:

```
prompt pure
ZSH_THEME=othertheme
source $ZSH/oh-my-zsh.zsh
```

And in this case, we show a warning, because there's no telling what
that OMZ theme might have done (precmd hooks, etc).
  • Loading branch information
mafredri committed Aug 12, 2018
1 parent 5976e54 commit 872153f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pure.zsh
Expand Up @@ -192,6 +192,12 @@ prompt_pure_precmd() {

# print the preprompt
prompt_pure_preprompt_render "precmd"

if [[ -n $ZSH_THEME ]]; then
print "WARNING: Oh My Zsh themes are enabled (ZSH_THEME='${ZSH_THEME}'). Pure might not be working correctly."
print "For more information, see: https://github.com/sindresorhus/pure#oh-my-zsh"
unset ZSH_THEME # Only show this warning once.
fi
}

prompt_pure_async_git_aliases() {
Expand Down Expand Up @@ -606,6 +612,8 @@ prompt_pure_setup() {
# Improve the debug prompt (PS4), show depth by repeating the +-sign and
# add colors to highlight essential parts like file and function name.
PROMPT4="${ps4_parts[depth]} ${ps4_symbols}${ps4_parts[prompt]}"

unset ZSH_THEME # Guard against Oh My Zsh themes overriding Pure.
}

prompt_pure_setup "$@"

0 comments on commit 872153f

Please sign in to comment.