From e786ef6448f910a50f90b48967421e91cb5c49c6 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 8 Jan 2021 18:26:24 +0200 Subject: [PATCH] [zsh] re-define j to use fzf for selection instead of fasd's algorithm --- zsh/plugins.zsh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/zsh/plugins.zsh b/zsh/plugins.zsh index f446394..edba661 100644 --- a/zsh/plugins.zsh +++ b/zsh/plugins.zsh @@ -62,6 +62,27 @@ _plugin completions 'zsh-users/zsh-completions' "$_checkout_latest_version" # }}} +# fasd {{{ + +unalias j +j() { + local _fasd_ret + _fasd_ret="$( + # -l: list all paths in the database (without scores) + # -d: list only directories + # -R: in the reverse order + fasd -l -d -R | + fzf --height=40% --layout=reverse --tiebreak=index --query="$*" + )" + if [[ -d "$_fasd_ret" ]]; then + cd -- "$_fasd_ret" + elif [[ -n "$_fasd_ret" ]]; then + print -- "$_fasd_ret" + fi +} + +# }}} + # _plugin fzf 'junegunn/fzf' "$_checkout_latest_version" \ # build='./install --bin' \ # after_load='plugin-cfg-path path prepend bin' \