Skip to content

Commit

Permalink
Don't complete ancestor dirs as recent dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Aug 22, 2023
1 parent dc22275 commit a46347b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Functions/Init/.autocomplete__recent-dirs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ ${0}:precmd() {
add-zsh-hook chpwd +autocomplete:recent-directories:save

+autocomplete:recent-directories() {
# Don't complete current dir, its children, or nonexistent ones.
typeset -ga reply=( ${^dirstack[@]:#$PWD(|/[^/]#)}(N) )

local -P ancestor=$PWD:h
while [[ $ancestor != / ]]; do
reply=( ${reply[@]:#$ancestor} )
ancestor=$ancestor:h
done

local exact=$reply[(r)*/$PREFIX$SUFFIX]
[[ -n $exact ]] &&
reply=( $exact ${reply[@]:#$exact} )
local -i exact=$reply[(i)*/$PREFIX$SUFFIX]
(( exact )) &&
reply=( $reply[exact] $reply[1,exact-1] $reply[exact+1,-1] )

(( $#reply[@] ))
}
Expand Down

0 comments on commit a46347b

Please sign in to comment.