-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[question] elegant way to call function in an previous instead of call script file #3599
Comments
hmmm.... I realized that maybe I can use $ env |
sed -r 's/^([a-zA-Z0-9_-]+)=(.*)$/\1 \2/' |
fzf --delimiter=' ' \
--preview='source ~/.marslo/bin/bash-color.sh; echo -e "$(c Ys)>> {1}$(c)\n$(c Wi).. {2}$(c)"' \
--with-nth=1 getenv-preview.movbut I'm still curious how to call function instead of scripts, for more complex process to preview |
suddenly realized that, I'm struggling for so long is because of I was using here are details:
details: fzf-preview-single-double-quotes.movmy environment: $ sw_vers
ProductName: macOS
ProductVersion: 14.2.1
BuildVersion: 23C71
$ bash --version
GNU bash, version 5.2.26(1)-release (x86_64-apple-darwin23.2.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ fzf --version
0.45.0 (brew) |
Functions are not visible to child processes unless they are exported with #!/usr/bin/env bash
foo() {
echo foo
}
export -f foo
fzf --preview 'foo' Note Please note, if your login shell isn't
fzf starts child processes using Alternatives:
foo=$'echo foo'
: | fzf --preview "$foo"
foo() {
echo foo
}
: | fzf --preview 'source /path/to/file/with/function; foo' |
for alternatives solution, how to handle
I've tried: : | env | sed ... | fzf # < not working
env | sed ... | : | fzf # < not working |
I'm not entirely clear on the problem. The colon foo=$'input={};echo "${!input}"'
command env | sed -rn 's/^([a-zA-Z0-9]+)=.*$/\1/p' | SHELL=bash fzf --preview "$foo" Footnotes |
man fzf
)Info
Problem / Steps to reproduce
The question is inspired from
$ unset **<TAB>
. I'd like to have a function to enhance the format and something else for environment variable.So, theoretical basis to get value of variable value:
I had a function (
getenv
for example ) as below:however, in the fzf preview window, it shows issue:
/usr/local/bin/bash: line 1: _echo_values: command not found
And the bash works:
I've tried to move
_echo_values()
inside of functiongetenv()
as below, but still no lucky:So, I tried to move the
_echo_values()
to separate files and it works:I'd like to know whether if any elegant way can handle call a function in
--preview
instead of call a shell script fileThe text was updated successfully, but these errors were encountered: