Skip to content

Commit

Permalink
Fix support for autoloaded prompt themes in $fpath
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed May 19, 2023
1 parent 4ec387d commit 513742f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
18 changes: 8 additions & 10 deletions functions/.znap.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ zmodload -F zsh/zleparameter p:widgets
autoload -Uz add-zsh-hook add-zle-hook-widget promptinit

.znap.prompt() {
if (( # )); then
local gitdir=''
..znap.repos-dir
local theme=

if (( # )); then
if [[ $1 == */* ]]; then
.znap.clone $1 ||
return
fi
private _P__repo=~[$1]

private _P__theme=${2:-${${_P__repo##*/((oh-my-|)zsh-|)}%%((-zsh|)-(prompt|theme)|.zsh)}}
.znap.prompt.load $_P__repo $_P__theme
local theme=
.znap.prompt.load "$1"
fi

..znap.tput civis # Make cursor invisible.
Expand All @@ -32,12 +30,12 @@ autoload -Uz add-zsh-hook add-zle-hook-widget promptinit
exec 2> $_znap_prompt_tmp # Redirect std err to tmp file.

promptinit
if [[ -n $_P__theme ]]; then
prompt_themes+=( $_P__theme )
prompt $_P__theme
if [[ -n $theme ]]; then
prompt_themes+=( $theme )
prompt $theme
..znap.tput sc # Save cursor position (overwriting the previous save).

private _P__precmd=prompt_${_P__theme}_precmd
private _P__precmd=prompt_${theme}_precmd
if [[ -n $functions[$_P__precmd] ]]; then
$_P__precmd

Expand Down
8 changes: 7 additions & 1 deletion functions/.znap.prompt.load
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ zmodload -F zsh/parameter p:functions
.znap.prompt.load() {
emulate -L zsh; setopt $_znap_opts

private dir=$1 theme=$2
private setup=prompt_${theme}_setup

[[ -v functions[$setup] ]] &&
Expand All @@ -15,6 +14,13 @@ zmodload -F zsh/parameter p:functions

unfunction $setup

local repos=()
local gitdir=
..znap.repos prompt $theme
private dir=$gitdir/$repos[1]

theme=${2:-${${dir##*/((oh-my-|)zsh-|)}%%((-zsh|)-(prompt|theme)|.zsh)}}

private -a file=( $dir/**/$setup(-.Y1) )
if [[ -n $file ]]; then

Expand Down

0 comments on commit 513742f

Please sign in to comment.