declare
Inspect and manipulate Bash variables and functions, often combined with compgen for shell introspection
List all declared shell functions
declare -F | gawk '{ a[$3] } END { n=asorti(a,b); for (i=1;i<=n;i++) print b[i] }'
Show full definition of all functions
declare -f
Display definition of a specific function
declare -f my_function
List functions matching a pattern
compgen -A function | grep '^git'
Print function definitions for matched functions
declare -f $(compgen -A function | grep '^git')
Check if a function is defined
compgen -A function | grep -qx my_function && echo "defined"
Export a function to child shells
declare -fx my_function
List only exported functions
declare -F | awk '$3=="-x"{print $1}'
Remove (unset) a function
unset -f my_function
Dump all function names with line numbers
declare -F