Closed timkelty closed 6 months ago
Do you mind posting your setup? In mine, I have the following:
export FZF_CTRL_T_OPTS='--tiebreak=index --bind tab:down --bind shift-tab:up'
I think the --tiebreak=index
might be important here
Here's the extend of it:
# Source this before modules, since I like
# history-search-multi-word's ⌘R better
export FZF_CTRL_T_COMMAND='command cat <(fre --sorted) <(fd -t d) <(fd -t d . ~)'
export FZF_CTRL_T_OPTS="--tiebreak=index"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# https://github.com/camdencheek/fre
fre_purge() {
fre --sorted | while read dir ; do if [ ! -d "$dir" ] ; then fre --delete "$dir"; fi ; done
}
fre_chpwd() {
fre --add "$(pwd)"
}
typeset -gaU chpwd_functions
chpwd_functions+=fre_chpwd
~/.fzf.zsh
is just the standard one from fzf: https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh
I'm noticing now that the paths added by fre
are absolute, while the ones from fd
are relative. Seems like it could be the culprit?
Doesn't seem to, I added --absolute-path
to the fd
commands and the sorting seems unchanged.
Is the problem here due to the frecency scores not being weighted against fzf's matching scores? It seems that the frecency score would need to be a component of the matching score produced by fzf using something like a weighted average between the two.
I don't actually use the cat <(fre --sorted) <(fd -t d)
anymore, but I can easily reproduce your problem.
/tmp/list1
:
/absolute/abc
/absolute/def
/absolute/ghi
/tmp/list2
:
abc
def
ghi
If I run cat /tmp/list1 /tmp/list2 | fzf --tiebreak=index
and type bc
, abc
is ranked higher than /absolute/abc
.
It looks like this may be due to a change in the fzf ranking algorithm that means that exact matches are very rare, so --tiebreak=index
is no longer as effective for our use case.
Since the output of fre
is already sorted, it would probably work well to add the --no-sort
option to fzf
so that it doesn't try to apply its re-ranking. That way it just acts as a fast filter. This seems to work well for my toy example.
If you try this out, could you let me know how it works? Would be nice to update the docs examples to work well with newer versions of fzf
.
@camdencheek – yeah that seems to work pretty well, thanks!
Here's what I have now:
export FZF_CTRL_T_COMMAND='command cat <(fre --sorted) <(fd --absolute-path -t d ) <(fd --absolute-path -t d . ~)'
I don't actually use the cat <(fre --sorted) <(fd -t d) anymore
Out of curiosity, do you just use FZF_CTRL_T_COMMAND='command fre --sorted'
, or something else?
Migrating from straight fzf search + z/autojump (as I figure most people ending up here likely are), while initially intriguing, I'm not sure I'm sold on the idea of combining them into a single command (CTRL-T or otherwise)
FWIW, here's a fun alternative to cat
ing the fre
and fd
results together in one list:
export FZF_CTRL_T_COMMAND='fre --sorted'
export FZF_CTRL_T_OPTS="
--prompt 'Favorites> '
--header 'CTRL-T: Favorites / CTRL-D: Directories / CTRL-F: Files'
--bind 'ctrl-d:change-prompt(Directories> )+reload(fd -t d .)'
--bind 'ctrl-f:change-prompt(Files> )+reload(fd -t f .)'
--bind 'ctrl-t:change-prompt(Favorites> )+reload($FZF_CTRL_T_COMMAND)'
"
Out of curiosity, do you just use FZF_CTRL_T_COMMAND='command fre --sorted', or something else?
Yep, just export FZF_CTRL_T_COMMAND='fre --sorted'
here's a fun alternative
Oh, that's neat! I'll have to give it a try -- thanks 😄
Apologies for posting here, as I'm quite certain this is more of an
fzf
question, but your default fre+fzf setup seems to be exactly what I'm looking for, so thought you might have some insight.One bit I'm not clear on, is why in this scenario:
/Users/timkelty/Dev/cloud-extension-yii2
doesn't bubble to the top once I start searchingyii2
. Before any query, the results are listed just asfre
has them, but once I type a query, this folder gets unexpectedly pushed pretty far down, even though it should have preferential weight fromfre
.