Alternative fzf modes #144
Replies: 6 comments
-
I copied but I made it better. It follows zoxide's fzf options. So you will have identical result if you use zoxide |
Beta Was this translation helpful? Give feedback.
-
@zethnest commented on Oct 6, 2020, 12:49 PM GMT+3:30:
Check out my latest design at https://github.com/NightMachinary/.shells/blob/master/scripts/zsh/interactive/auto-load/fuzzy/z.zsh (it uses https://github.com/NightMachinary/.shells/blob/master/scripts/zsh/basic/auto-load/memoi.zsh for caching). It's pretty fantastic; It auto-learns your choices, you can easily veto the last choice via PS: If you find you don't have some function, here is an auto-generated list of functions that code might have used:
|
Beta Was this translation helpful? Give feedback.
-
@zethnest commented on Oct 6, 2020, 12:49 PM GMT+3:30:
Check out my latest design at https://github.com/NightMachinary/.shells/blob/master/scripts/zsh/interactive/auto-load/fuzzy/z.zsh (it uses https://github.com/NightMachinary/.shells/blob/master/scripts/zsh/basic/auto-load/memoi.zsh for caching). It's pretty fantastic; It auto-learns your choices, you can easily veto the last choice via PS: If you find you don't have some function, here is an auto-generated list of functions that code might have used:
|
Beta Was this translation helpful? Give feedback.
-
Hey @NightMachinary and @zethnest, I've moved this issue to GitHub Discussions. Scripts like this cannot be put directly onto a wiki without thorough testing, but Discussions is a great place for something like this. |
Beta Was this translation helpful? Give feedback.
-
Y'all should use |
Beta Was this translation helpful? Give feedback.
-
Here is my take: d () { cd $(zf "$@") } And this is the #!/bin/sh
# Quick directory switcher based on zoxide and fzf
if test -d "$1" -o "$1" = "-"
then echo "$@"
else
set -o noglob
query=$(zoxide query -sl "$@")
# First find out whether there is an obvious match (score at least ten times that of runner-up)
# If not select with fzf, using locate to find extra options
( expr $(echo "$query" | sed 'N;s|/.*\n|> 10 *|;q' | sed 's| */.*||') >/dev/null &&
echo "$query" | head -1 ||
( echo "$query"; locate --basename --existing "$@" | while read -r file; do test -d "$file" && echo "
$file"; done | sed 's/^/ 0 /' ) |
fzf -0 -1 -n2.. --tiebreak=index --preview="ls -a --color --human-readable --group-directories-first
--file-type {2..}" --preview-window=20% ) | tr -s ' ' | cut -d' ' -f3-
fi |
Beta Was this translation helpful? Give feedback.
-
I find this design better, both in the interactive usage and noninteractive:
Here is a demo.
I wanted to add it to the wiki but the wiki seems disabled?
Beta Was this translation helpful? Give feedback.
All reactions