From a809e1548b6679ba77fc4b83f437c911c474e0a1 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Mon, 2 Apr 2001 12:24:46 +0000 Subject: [PATCH] moved from ./Functions/Misc/cdmatch2 --- Functions/Compctl/cdmatch2 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Functions/Compctl/cdmatch2 diff --git a/Functions/Compctl/cdmatch2 b/Functions/Compctl/cdmatch2 new file mode 100644 index 000000000..8a3e9591f --- /dev/null +++ b/Functions/Compctl/cdmatch2 @@ -0,0 +1,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 extendedglob +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