Skip to content

Commit

Permalink
Optimize dynamic dir lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Mar 9, 2021
1 parent 213fc51 commit 68b7c64
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions functions/:znap:dirname
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ local repo
case $1 in
n)
() {
emulate -L zsh; setopt $_znap_opts

emulate -L zsh; setopt extendedglob
repo=~znap/$2
if [[ $2 == */* ]]; then
repo=~znap/${${2##*/}%.git}
Expand All @@ -20,14 +19,12 @@ case $1 in
;;
d)
() {
emulate -L zsh; setopt $_znap_opts

for repo in ~znap/*(-/); do
if [[ $2 == $repo(|/*) ]]; then
reply=( $repo:t $#repo )
return 0
fi
done
emulate -L zsh; setopt extendedglob
if [[ $2 == ~znap/* ]]; then
repo=${${2#~znap/}:h1}
reply=( $repo ${#:-~znap/$repo} )
return 0
fi
return 66
} "$@"
;;
Expand Down

0 comments on commit 68b7c64

Please sign in to comment.