about summary refs log tree commit diff
path: root/Functions/Compctl/cdmatch2
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 12:24:46 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 12:24:46 +0000
commita809e1548b6679ba77fc4b83f437c911c474e0a1 (patch)
tree548cce36f818009c40112bb8c31cb5c73b1cc70d /Functions/Compctl/cdmatch2
parentd3a4878b68e8b3217ee26e2604be71e9dd11aad3 (diff)
downloadzsh-a809e1548b6679ba77fc4b83f437c911c474e0a1.tar.gz
zsh-a809e1548b6679ba77fc4b83f437c911c474e0a1.tar.xz
zsh-a809e1548b6679ba77fc4b83f437c911c474e0a1.zip
moved from ./Functions/Misc/cdmatch2
Diffstat (limited to 'Functions/Compctl/cdmatch2')
-rw-r--r--Functions/Compctl/cdmatch215
1 files changed, 15 insertions, 0 deletions
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