Closed callumacrae closed 2 years ago
foo() {
echo foo
}
# You should export the function
export -f foo
fzf --preview 'foo'
Thanks!
For anyone else who finds this issue, the problem was that functions aren't available to child processes.
Unfortunately in ZSH, it looks like you can't export functions - the recommended alternative is to use autoloaded functions instead, or you could make a proper script and add it to your $PATH
.
I just put all my scripts in big strings 🤷♂️
man fzf
)Info
Problem / Steps to reproduce
I feel like this must have come up before but was unable to find an issue!
I'm trying to bind a key to execute a function set in the shell—set locally for demo purposes but the same happens in .zshrc files.
It fails in zsh:
It fails in bash too:
I've tried to look into the source to figure it out myself but am unfamiliar with how Go works so struggled to make any progress: https://github.com/junegunn/fzf/blob/cd2340141100e057005d31e653c0ce7a0f7a4af7/src/util/util_unix.go#L12