+# Select directories with z(1)
+if [[ -r "$HOME/sandbox/_misc/z/z.sh" ]]; then
+ source "$HOME/sandbox/_misc/z/z.sh"
+
+ function percol_select_directory() {
+ local -a tac_cmd
+ tac_cmd=($(find_tac_command))
+
+ local selected
+ selected=$(_z -r 2>&1 | \
+ "${tac_cmd[@]}" | \
+ percol --query "$LBUFFER" | \
+ sed -r 's/[^[:space:]]+[[:space:]]+//')
+
+ if [[ $? -eq 0 ]]; then
+ cd "${selected}"
+ selected="" # Without this, zsh treats this variable as a
+ # candidate for a "named directory".
+ fi
+
+ zle reset-prompt
+ return 0
+ }
+
+ if which percol >&/dev/null; then
+ zle -N percol_select_directory
+ bindkey '\C-xd' percol_select_directory
+ fi
+fi
+