Closed og900aero closed 5 months ago
Evaluating fzf --bash
does take some time, but 340ms seems a bit too much. Can you measure the exact the time like so?
$ time fzf --bash > /dev/null
real 0m0.021s
user 0m0.003s
sys 0m0.009s
$ time eval "$(fzf --bash)"
real 0m0.051s
user 0m0.021s
sys 0m0.023s
Personally, I only added the eval "$(fzf --bash)" because of the CTRL+R function.
fzf --bash
prints both scripts in https://github.com/junegunn/fzf/tree/master/shell. You can strip out the unwanted part as discussed in https://github.com/junegunn/fzf/pull/3675,
$ time eval "$(fzf --bash | sed -n '/### key-bindings/,/### end/p')"
real 0m0.023s
user 0m0.005s
sys 0m0.012s
or you can just load the individual file (https://github.com/junegunn/fzf/blob/master/shell/key-bindings.bash) instead of using fzf --bash
Thx for your answer. My values:
$ time fzf --bash > /dev/null
real 0m0.021s
user 0m0.017s
sys 0m0.006s
$ time eval "$(fzf --bash)"
real 0m0.440s
user 0m0.337s
sys 0m0.126s
$ time eval "$(fzf --bash | sed -n '/### key-bindings/,/### end/p')"
real 0m0.059s
user 0m0.035s
sys 0m0.030s
$ time source ~/key-bindings.bash
real 0m0.017s
user 0m0.011s
sys 0m0.007s
So I stay source keybindings.bash file. Thx for your help! And thank you for your work. fzf is at least as important as a sed or awk command.
Checklist
man fzf
)Output of
fzf --version
0.50.0 (f97d275)
OS
Shell
Problem / Steps to reproduce
If I put eval "$(fzf --bash)" at the end of .bashrc, then the prompt appears much slower than without it:
Without eval "$(fzf --bash)": 0.077sec With eval "$(fzf --bash)": 0.419sec
Personally, I only added the eval "$(fzf --bash)" because of the CTRL+R function. Maybe there is a special way to implement only the CTRL+R function in it and not need the eval "$(fzf --bash)"? Because then I think it would be possible to speed it up.