In zsh, how can one know which file a completion function is defined in or comes from?
which
can print the source code of a completion but it does not give any information about where I can find the file that contains the completion script. For instance, which _git
in a zsh shell gives the following output:
❯❯❯ which _git
_git () {
local _ret=1
local cur cword prev
#... (omitted) ...
let _ret && _default && _ret=0
return _ret
}
whereas which git
(commands or executables) gives the exact path(s):
❯❯❯ which -a git
/opt/homebrew/bin/git
/usr/bin/git
I know the completion functions must be somewhere in $fpath
, so one could search $fpath
to find a _completion
file.
❯❯❯ for f in $fpath; do \ls $f/_git 2>/dev/null; done
/opt/homebrew/share/zsh/site-functions/_git
/opt/homebrew/Cellar/zsh/5.9/share/zsh/functions/_git
But is there any easy way or built-in command for doing this?
type _git
gives me:_git is a shell function from /usr/share/zsh/functions/Completion/Unix/_git