about summary refs log tree commit diff
path: root/Functions/Chpwd
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2011-03-11 16:32:07 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-03-11 16:32:07 +0000
commitf2dca9e155f25ee57f15df7dc2dc81489e1abbae (patch)
tree7fcb3500f0c2c7d66b12fe3a50e92e2913d26cc7 /Functions/Chpwd
parentcc69ecfb9e10fca2d8f68100ff9f2365dedb1405 (diff)
downloadzsh-f2dca9e155f25ee57f15df7dc2dc81489e1abbae.tar.gz
zsh-f2dca9e155f25ee57f15df7dc2dc81489e1abbae.tar.xz
zsh-f2dca9e155f25ee57f15df7dc2dc81489e1abbae.zip
users/15864: turn zsh_directory_name into a hook
Diffstat (limited to 'Functions/Chpwd')
-rw-r--r--Functions/Chpwd/.distfiles1
-rw-r--r--Functions/Chpwd/zsh_directory_name_cdr25
2 files changed, 26 insertions, 0 deletions
diff --git a/Functions/Chpwd/.distfiles b/Functions/Chpwd/.distfiles
index 39ccd830c..89779a686 100644
--- a/Functions/Chpwd/.distfiles
+++ b/Functions/Chpwd/.distfiles
@@ -5,4 +5,5 @@ _cdr
 chpwd_recent_add
 chpwd_recent_dirs
 chpwd_recent_filehandler
+zsh_directory_name_cdr
 '
diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr
new file mode 100644
index 000000000..09aa35a93
--- /dev/null
+++ b/Functions/Chpwd/zsh_directory_name_cdr
@@ -0,0 +1,25 @@
+if [[ $1 = n ]]; then
+  if [[ $2 = <-> ]]; then
+    # Recent directory
+    typeset -ga reply
+    autoload -Uz cdr
+    cdr -r
+    if [[ -n ${reply[$2]} ]]; then
+      reply=(${reply[$2]})
+      return 0
+    else
+      reply=()
+      return 1
+    fi
+  fi
+elif [[ $1 = c ]]; then
+  if [[ $PREFIX = <-> || -z $PREFIX ]]; then
+    typeset -a keys values
+    values=(${${(f)"$(cdr -l)"}/ ##/:})
+    keys=(${values%%:*})
+    _describe -t dir-index 'recent directory index' \
+      values keys -V unsorted -S']'
+    return
+  fi
+fi
+return 1