about summary refs log tree commit diff
path: root/Functions/Misc/cdmatch
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-06-08 09:26:01 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-06-08 09:26:01 +0000
commitfcd7cd1cfa2ba286f4bf73da7a60116cd3912629 (patch)
treed2aa5a9369bf3af8841d3abde69f52bd483f5526 /Functions/Misc/cdmatch
parentb39cafaa22ad7efc2ac4b64a5eeac8f49bc80e00 (diff)
downloadzsh-fcd7cd1cfa2ba286f4bf73da7a60116cd3912629.tar.gz
zsh-fcd7cd1cfa2ba286f4bf73da7a60116cd3912629.tar.xz
zsh-fcd7cd1cfa2ba286f4bf73da7a60116cd3912629.zip
Initial revision
Diffstat (limited to 'Functions/Misc/cdmatch')
-rwxr-xr-xFunctions/Misc/cdmatch23
1 files changed, 23 insertions, 0 deletions
diff --git a/Functions/Misc/cdmatch b/Functions/Misc/cdmatch
new file mode 100755
index 000000000..7c4bb9ae7
--- /dev/null
+++ b/Functions/Misc/cdmatch
@@ -0,0 +1,23 @@
+# Start of cdmatch.
+# Save in your functions directory and autoload, then do
+# compctl -x 'S[/][~][./][../]' -g '*(-/)' - \
+#         'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd
+#
+# Completes directories for cd, pushd, ... anything which knows about cdpath.
+# You do not have to include `.' in your cdpath.
+#
+# It works properly only if $ZSH_VERSION > 3.0-pre4.  Remove `emulate -R zsh'
+# for all other values of $ZSH_VERSION > 2.6-beta2. For earlier versions
+# it still works if RC_EXPAND_PARAM is not set or when cdpath is empty.
+emulate -R zsh
+setopt localoptions
+local narg pref cdp
+
+read -nc narg
+read -Ac pref
+
+cdp=(. $cdpath)
+reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t) )
+
+return
+# End of cdmatch.