summaryrefslogtreecommitdiff
path: root/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Chpwd/.distfiles1
-rw-r--r--Functions/Chpwd/zsh_directory_name_cdr25
-rw-r--r--Functions/Misc/add-zsh-hook7
3 files changed, 31 insertions, 2 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
diff --git a/Functions/Misc/add-zsh-hook b/Functions/Misc/add-zsh-hook
index aedc1e754..c49688643 100644
--- a/Functions/Misc/add-zsh-hook
+++ b/Functions/Misc/add-zsh-hook
@@ -1,6 +1,6 @@
# Add to HOOK the given FUNCTION.
# HOOK is one of chpwd, precmd, preexec, periodic, zshaddhistory,
-# zshexit (the _functions subscript is not required).
+# zshexit, zsh_directory_name (the _functions subscript is not required).
#
# With -d, remove the function from the hook instead; delete the hook
# variable if it is empty.
@@ -15,7 +15,10 @@
emulate -L zsh
local -a hooktypes
-hooktypes=(chpwd precmd preexec periodic zshaddhistory zshexit)
+hooktypes=(
+ chpwd precmd preexec periodic zshaddhistory zshexit
+ zsh_directory_name
+)
local opt
local -a autoopts