I am using zsh
and I have defined few utility shell function in some shell scripts, few of them called from ~/.zshrc
, so let's assume that we don't know the location of these functions. One function is:
function k.pstree.n {
if [ "$1" != "" ]
then
pstree -p | grep -C3 "$1"
else
printf " Please specify the name of the process you want to show!\n"
fi
}
How can I print the code of that shell function?
I can think of a search & grep like:
find $(pwd) -name "*sh*" -type f -printf "\"%p\"\n" | xargs grep -C5 "k.pstree.n"
but this assumes that I roughly know the location which is not true here.
declare -f
, answered in stackoverflow. In my casedeclare -f k.pstree.n
.