Skip to content

Commit

Permalink
Support prompt themes that don't have a repo
Browse files Browse the repository at this point in the history
Fixes #163.
  • Loading branch information
marlonrichert committed Feb 22, 2022
1 parent e019e00 commit aa8396a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
5 changes: 1 addition & 4 deletions functions/.znap.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ autoload -Uz add-zsh-hook add-zle-hook-widget promptinit
[[ $1 == */* ]] &&
repo=~[$1]
private theme=${2:-${${repo##*/((oh-my-|)zsh-|)}%%((-zsh|)-(prompt|theme)|.zsh)}}
if ! .znap.prompt.load $repo $theme; then
print -u2 'znap prompt: no such theme:' $@
return $(( sysexits[(i)NOINPUT] + 63 ))
fi
.znap.prompt.load $repo $theme
fi

..znap.tput civis # Make cursor invisible.
Expand Down
30 changes: 17 additions & 13 deletions functions/.znap.prompt.load
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ zmodload -F zsh/parameter p:functions

file=( $dir/**/*$theme*.{zsh-theme,plugin.zsh,.zsh}(-.Y1) )

[[ -n $file ]] ||
return
if [[ -n $file ]]; then
eval "$setup() {
unsetopt localoptions prompt{bang,cr,percent,sp,subst}
PS1='%# '
. $file[1]
private opt=
for opt in bang cr percent sp subst; do
[[ -o prompt\$opt ]] &&
prompt_opts+=( \$opt )
done
setopt localoptions
}"
return
fi

eval "$setup() {
unsetopt localoptions prompt{bang,cr,percent,sp,subst}
PS1='%# '
. $file[1]
private opt=
for opt in bang cr percent sp subst; do
[[ -o prompt\$opt ]] &&
prompt_opts+=( \$opt )
done
setopt localoptions
}"
$setup() {
prompt_opts=( bang cr percent sp subst )
}
}

.znap.prompt.load "$@"

0 comments on commit aa8396a

Please sign in to comment.