Last active
February 10, 2021 20:13
-
-
Save chew-z/44f3bcdc08eaecdf306868f9a3d0eddd to your computer and use it in GitHub Desktop.
fzf-z z on [fzf] steroids
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# # fzf-z - magic powers of z & fzf combined - | |
# ALT-Z -> recent folders history and goto | |
# place in /usr/local/share/zsh/site-functions/ | |
# and add to your .zshrc | |
# source /usr/local/share/zsh/site-functions/fzf-z | |
# | |
# Based on https://github.com/andrewferrier/fzf-z | |
__fzf-z() { | |
RECENTLY_USED_DIRS="{ z -l | sed 's/^[[:digit:].]*[[:space:]]*//' }" | |
FZF_COMMAND='fzf --tac --tiebreak=index -m --preview="tree -C {} | head -$LINES" --preview-window=right:50%' | |
# FZF_COMMAND='fzf --tac --tiebreak=index -m --preview="ls -1 {} | head -$LINES"' | |
local COMMAND="{ $RECENTLY_USED_DIRS } | $FZF_COMMAND" | |
eval "$COMMAND" | while read item; do | |
printf '%q ' "$item" | |
done | |
echo | |
} | |
fzf-z-file-widget() { | |
LBUFFER="${LBUFFER}$(__fzf-z)" | |
local ret=$? | |
zle redisplay | |
typeset -f zle-line-init >/dev/null && zle zle-line-init | |
return $ret | |
} | |
zle -N fzf-z-file-widget | |
bindkey '\ez' fzf-z-file-widget |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment