我正在使用zsh
并且在一些 shell 脚本中定义了一些实用程序 shell 函数,其中很少有调用 from ~/.zshrc
,所以假设我们不知道这些函数的位置。一个功能是:
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
}
Run Code Online (Sandbox Code Playgroud)
如何打印该shell函数的代码?
我可以想到像这样的搜索和 grep:
find $(pwd) -name "*sh*" -type f -printf "\"%p\"\n" | xargs grep -C5 "k.pstree.n"
Run Code Online (Sandbox Code Playgroud)
但这假设我大致知道此处不正确的位置。