Sample Header Ad - 728x90

Cannot Display Bash Functions within FZF Preview Window

1 vote
2 answers
1077 views
**How do I get the FZF Preview Window to Display Functions from my Current Bash Environment?** I want to list my custom bash functions using FZF, and view the code of a selected function in the FZF Preview Window. However, it does not appear that the bash enviroment used by FZF to execute my command can see the functions in my terminal bash environment. For example:
$ declare -F | fzf --preview="type {3}"

/bin/bash: line 1: type: g: not found
enter image description here However, the following works:
$ declare -F

declare -f fcd
declare -f fz
declare -f g

$ type g
g is a function
g ()
{
    search="";
    for term in $@;
    do
        search="$search%20$term";
    done;
    nohup google-chrome --app-url "http://www.google.com/search?q=$search " > /dev/null 2>&1 &
}

declare -F | fzf --preview="echo {3}"

g # my function g()
One reason I suspect that the FZF Preview Window environment may not be able to see my terminal environment is because they have different process ID's.
$ echo $BASHPID

1129439

$ declare -F | fzf --preview="echo $BASHPID"

1208203
**How do I get the FZF Preview Window to Display Functions from my Current Bash Environment?**
Asked by user2514157 (225 rep)
Oct 21, 2022, 03:10 PM
Last activity: Jun 11, 2025, 07:38 AM