summary refs log tree commit diff
path: root/Functions/cdmatch2
blob: c70357a340d9b87f05ff1d51b220f44b79e4ab4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# This function should be called from compctl to complete the
# second argument of cd and pushd.

emulate -R zsh				# Requires zsh 3.0-pre4 or later
setopt localoptions
local from

read -Ac from
from="${from[2]}"

eval "reply=( \${PWD:s@$from@$1*$2@}~$PWD(ND-/:) )"
reply=( "${${reply[@]#${PWD%%$from*}}%${PWD#*$from}}" )
[[ ${#reply[(r),-1]} != 0 ]] && reply[(r)]="''"

return