How do I show the definition of a function in zsh? type foo doesn’t give the definition.
In bash:
bash$ function foo() { echo hello; }
bash$ foo
hello
bash$ type foo
foo is a function
foo ()
{
echo hello
}
In zsh:
zsh$ function foo() { echo hello; }
zsh$ foo
hello
zsh$ type foo
foo is a shell function
The zsh idiom is
whence, the-fflag prints function definitions:In zsh,
typeis defined as equivalent towhence -v, so you can continue to usetype, but you’ll need to use the-fargument:And, finally, in zsh
whichis defined as equivalent towhence -c– print results in csh-like format, sowhich foowill yield the same results.man zshbuiltinsfor all of this.