mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-11 10:41:12 +02:00
43 lines
1 KiB
Text
43 lines
1 KiB
Text
#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/ - "$friends[@]"' or something like that.
|
|
|
|
local d s dirs list lines revlines i
|
|
|
|
if [[ "$SUFFIX" = */* ]]; then
|
|
ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
|
|
SUFFIX="${SUFFIX%%/*}"
|
|
s=(-S '')
|
|
else
|
|
s=(-qS/)
|
|
fi
|
|
|
|
if [[ -prefix [-+] ]]; then
|
|
lines=("$PWD" "$dirstack[@]")
|
|
integer i
|
|
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=(${lines%% *})
|
|
compset -P '[-+]'
|
|
_description d 'directory stack'
|
|
compadd "$d[@]" -V dirs -S/ -ld lines -Q - "$list[@]"
|
|
else
|
|
_users "$@"
|
|
if (( $# )); then
|
|
d=( "$@" )
|
|
else
|
|
_description d 'named directory'
|
|
fi
|
|
compadd "$d[@]" "$s[@]" - "${(@k)nameddirs}"
|
|
fi
|