Skip to content

Commit

Permalink
Merge pull request zsh-users#4 from hchbaw/for-nakamuray/source-cdr
Browse files Browse the repository at this point in the history
new source cdr
  • Loading branch information
nakamuray committed Oct 19, 2011
2 parents 2069e45 + 4414246 commit 6d12817
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sources/cdr.zsh
@@ -0,0 +1,35 @@
#
# zaw-src-cdr
#
# zaw source for recent directories
#

(( $+functions[cdr] )) || return

function zaw-src-cdr () {
: ${(A)candidates::=${${(f)"$(cdr -l)"}##<-> ##}}
actions=(zaw-src-cdr-cd zaw-src-cdr-insert zaw-src-cdr-prune)
act_descriptions=("cd" "insert" "prune")
options+=(-m)
}

function zaw-src-cdr-cd () {
BUFFER="cd $1"
zle accept-line
}

function zaw-src-cdr-insert () {
[[ -z "$LBUFFER" ]] || LBUFFER+=" "
[[ "$LBUFFER[-1]" == " " ]] || LBUFFER+=" "
LBUFFER+="${(j. .)@}"
}

function zaw-src-cdr-prune () {
local -aU reply
autoload -Uz chpwd_recent_filehandler
chpwd_recent_filehandler
: ${(A)reply::=${reply:#(${(~j.|.)${~@}})}}
chpwd_recent_filehandler $reply
}

zaw-register-src -n cdr zaw-src-cdr

0 comments on commit 6d12817

Please sign in to comment.