Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The prompt appears slowly #3751

Closed
5 of 10 tasks
og900aero opened this issue Apr 24, 2024 · 2 comments
Closed
5 of 10 tasks

The prompt appears slowly #3751

og900aero opened this issue Apr 24, 2024 · 2 comments

Comments

@og900aero
Copy link

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.50.0 (f97d275)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

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.

@junegunn
Copy link
Owner

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 #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

@og900aero
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants