1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-10-02 00:41:44 +02:00
zsh/Completion/Base/_tilde
2000-05-31 09:38:25 +00:00

57 lines
1.6 KiB
Plaintext

#compdef -tilde-
# We use all named directories and user names here. If this is too slow
# for you or if there are too many of them, you may want to use
# `compadd -qS/ -a friends' or something like that.
[[ -n "$compstate[quote]" ]] && return 1
local expl suf dirs list lines revlines i ret disp nm="$compstate[nmatches]"
if [[ "$SUFFIX" = */* ]]; then
ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
SUFFIX="${SUFFIX%%/*}"
suf=(-S '')
else
suf=(-qS/)
fi
_tags users named-directories directory-stack
while _tags; do
_requested users && _users "$suf[@]" "$@" && ret=0
_requested named-directories expl 'named directory' \
compadd "$suf[@]" "$@" -k nameddirs
if _requested directory-stack &&
{ ! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
[[ "$PREFIX" = [-+]* || nm -eq compstate[nmatches] ]] }; then
if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then
integer i
lines=("${PWD}" "${dirstack[@]}")
if [[ ( -prefix - && ! -o pushdminus ) ||
( -prefix + && -o pushdminus ) ]]; then
revlines=( $lines )
for (( i = 1; i <= $#lines; i++ )); do
lines[$i]="$((i-1)) -- ${revlines[-$i]}"
done
else
for (( i = 1; i <= $#lines; i++ )); do
lines[$i]="$((i-1)) -- ${lines[$i]}"
done
fi
list=( ${PREFIX[1]}${^lines%% *} )
disp=( -ld lines )
else
list=( ${PREFIX[1]}{0..${#dirstack}} )
disp=()
fi
_all_labels -V directory-stack expl 'directory stack' \
compadd "$suf[@]" "$disp[@]" -Q -a list && ret=0
fi
(( ret )) || return 0
done