Shell Command - type

Image of Author
March 18, 2022 (last updated September 21, 2022)

type tells you about the type of command you are inspecting. Tested on MacOS in Zsh.

type wow
# -> wow not found
function wow() { echo wow }
wow
# -> hey
type wow
# -> wow is a shell function
type cat
# -> cat is /bin/cat
type type
# -> type is a shell builtin

Assuming I have a custom shell function in ~/.zshrc called blah

type blah
# -> blah is a shell function from ~/.zshrc

Assuming I have an alias g for git in ~/.zshrc

type g
# -> g is an alias for git
type git
# -> git is /usr/bin/git

In zsh, the docs are in man zshbuiltins. There you learn that type is an alias for whence -v and takes almost the same flags as whence, which can also be found in man zshbuiltins.