about summary refs log tree commit diff
path: root/Functions/Chpwd/chpwd_recent_add
blob: 49ec8d1c630bf63c796d059baa91259457ca14c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Helper for chpwd_recent_dirs.
# Add a directory to the reply array unless we're skipping it.
# If skipping, return non-zero status.

local pat
local add=$1
local -a prune patterns

zstyle -a ':chpwd:' recent-dirs-prune prune
if (( ${#prune} )); then
  patterns=(${${prune:#^pattern:*}##pattern:})
fi

for pat in $patterns; do
  if [[ $add =~ ${~pat} ]]; then
    return 1
  fi
done

if [[ ${prune[(I)parent]} -ne 0 && $add = $reply[1]/* ]]; then
  # replace
  reply=($reply[2,-1])
fi
reply=($add $reply)