zoxide + fzf
change
commit 00966df0497f76c3af603483606a13a3303933df
author Alpha Chen <alpha.chen@brilliant.org>
date
parent 3b72b27e
diff --git a/.zshrc b/.zshrc
index 8cd5bb73..dc2265ea 100644
--- a/.zshrc
+++ b/.zshrc
@@ -166,6 +166,18 @@ fi
 # has to go after compinit
 if (( $+commands[zoxide] )); then
   eval "$(zoxide init zsh)"
+
+  # https://junegunn.github.io/fzf/examples/directory-nagivation/#integration-with-fzf
+  # https://junegunn.github.io/fzf/examples/directory-nagivation/#zoxidehttpsgithubcomajeetdsouzazoxide
+  unalias z 2> /dev/null
+  z() {
+    local dir=$(
+      zoxide query --list --score |
+      fzf --height 40% --layout reverse --info inline \
+          --nth 2.. --tac --no-sort --query "$*" \
+          --bind 'enter:become:echo {2..}'
+    ) && cd "$dir"
+  }
 fi
 
 # Define named directories: ~w <=> Windows home directory on WSL.