forked from carapace-sh/carapace-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzsh.sh
More file actions
29 lines (28 loc) · 658 Bytes
/
Copy pathzsh.sh
File metadata and controls
29 lines (28 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
setopt extendedglob
printf '%s\n' $fpath \
| xargs -I{} find -L {} -name '_*' 2>/dev/null \
| xargs head -n1 2>/dev/null \
| grep -v -F \
-e '==>' \
-e ' -k ' \
-e ' -K ' \
-e '#autoload' \
| sed -e 's/ -[^ ]\+//g' \
-e 's/^#compdef //' \
| tr " " "\n" \
| grep -v \
-e '^$' \
-e '=' \
-e '^_' \
-e '^-' \
-e '^.$' \
-e '^#compdef$' \
| while IFS= read -r compdef; do
if [[ "$compdef" == *[\[\]\*\#\(\)\|]* ]]; then
(print -rl -- ${(M)${(k)commands}:#${~compdef}}) 2>/dev/null
else
print -r -- "$compdef"
fi
done \
| sort \
| uniq