akinomyoga/blesh-contrib

Unable to call fzf function after load

Closed this issue · 1 comments

I followed the steps of README on how to integrate ble.sh with fzf, using the ".fzf.bash" file, and in the end fo that file,I tried to call the function '_fzf_setup_completion', but bash says "command not found."
When I try to use this function interactively in bash, it works again.
If I disable ble.sh (loading fzf normally), the function also works!
Does the 'ble-import' function run assyncronous? If so, what is the best place to use fzf functions?

Thanks

Does the 'ble-import' function run assyncronous?

This. If you specify -d to ble-import, the actual loading of the module is deferred and will later be performed in the idle state (i.e., in which the user does not input anything). This is to speed up the initialization.

If you would like to immediately use the functions defined inside the fzf completion, you can drop the option -d from the invocation of ble-import, i.e., use ble-import integration/fzf-completion instead of ble-import -d integration/fzf-completion.

Another way is to defer the custom settings until the actual loading of the module using ble/util/import/eval-after-load. Here is an example:

# Example (~/.blerc)

ble-import -d integration/fzf-completion
ble/util/import/eval-after-load integration/fzf-completion '_fzf_setup_completion foo bar'

If you have more settings, you might want to create a function:

# Example (~/.blerc)

ble-import -d integration/fzf-completion

function _my_fzf_custom_settings {
  _fzf_setup_completion foo bar

  # ... more settings

}
ble/util/import/eval-after-load integration/fzf-completion _my_fzf_custom_settings