mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-09 12:21:14 +02:00
zsh-workers/8181
This commit is contained in:
parent
8e6689380c
commit
d9e72bbb60
2 changed files with 16 additions and 16 deletions
|
@ -9,7 +9,7 @@
|
|||
|
||||
setopt localoptions extendedglob
|
||||
|
||||
local d s dirs list lines
|
||||
local d s dirs list lines revlines i
|
||||
|
||||
if [[ "$SUFFIX" = */* ]]; then
|
||||
ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
|
||||
|
@ -21,22 +21,23 @@ fi
|
|||
|
||||
if [[ -prefix [-+] ]]; then
|
||||
lines=(${(f)"$(dirs -v)"})
|
||||
integer i
|
||||
if [[ ( -prefix - && ! -o pushdminus ) ||
|
||||
( -prefix + && -o pushdminus ) ]]; then
|
||||
integer tot i
|
||||
for (( i = 1, tot = $#lines-1; i <= $#lines; i++, tot-- )); do
|
||||
lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}"
|
||||
revlines=( $lines )
|
||||
for (( i = 1; i <= $#lines; i++ )); do
|
||||
lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}"
|
||||
done
|
||||
else
|
||||
for (( i = 1, tot = 0; i <= $#lines; i++, tot++ )); do
|
||||
lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}"
|
||||
for (( i = 1; i <= $#lines; i++ )); do
|
||||
lines[$i]="$((i-1)) -- ${lines[$i]##[0-9]#[ ]#}"
|
||||
done
|
||||
fi
|
||||
list=(${lines%% *})
|
||||
|
||||
compset -P '[-+]'
|
||||
_description d 'directory stack'
|
||||
compadd "$d[@]" -ld lines -Q - "$list[@]"
|
||||
compadd "$d[@]" -V dirs -S/ -ld lines -Q - "$list[@]"
|
||||
else
|
||||
if (( $# )); then
|
||||
d=( "$@" )
|
||||
|
|
|
@ -34,28 +34,27 @@ elif [[ $PREFIX = [-+]* ]]; then
|
|||
# lazy to type pushd.
|
||||
IPREFIX=$PREFIX[1]
|
||||
PREFIX=$PREFIX[2,-1]
|
||||
local list lines ret=1
|
||||
local list lines revlines ret=1 i
|
||||
|
||||
# get the list of directories with their canonical number
|
||||
# and turn the lines into an array, removing the current directory
|
||||
lines=( ${${(f)"$(dirs -v)"}##0*} )
|
||||
if [[ ( $IPREFIX = - && ! -o pushdminus ) ||
|
||||
( $IPREFIX = + && -o pushdminus ) ]]; then
|
||||
# reverse the numbering: it counts the last one as -0, which
|
||||
# is a little strange.
|
||||
integer tot i
|
||||
for (( i = 1, tot = $#lines-1; i <= $#lines; i++, tot-- )); do
|
||||
lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}"
|
||||
integer i
|
||||
revlines=( $lines )
|
||||
for (( i = 1; i <= $#lines; i++ )); do
|
||||
lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}"
|
||||
done
|
||||
else
|
||||
for (( i = 1, tot = 1; i <= $#lines; i++, tot++ )); do
|
||||
lines[$i]="$tot -- ${lines[$i]##[0-9]#[ ]#}"
|
||||
for (( i = 1; i <= $#lines; i++ )); do
|
||||
lines[$i]="$i -- ${lines[$i]##[0-9]#[ ]#}"
|
||||
done
|
||||
fi
|
||||
# get the array of numbers only
|
||||
list=(${lines%% *})
|
||||
_description expl 'directory stack index'
|
||||
compadd "$expl[@]" -ld lines -Q - "$list[@]" && ret=0
|
||||
compadd "$expl[@]" -ld lines -V dirs -Q - "$list[@]" && ret=0
|
||||
[[ -z $compstate[list] ]] && compstate[list]=list && ret=0
|
||||
[[ -n $compstate[insert] ]] && compstate[insert]=menu && ret=0
|
||||
|
||||
|
|
Loading…
Reference in a new issue