If you want to know which program a command name will run in your current Mac Terminal session, first ask zsh how it interprets that name, then search PATH for executable files. This matters because a command can resolve to an alias or shell function before the shell reaches a file. On macOS, Terminal’s default shell is zsh, though a Terminal profile or administrator can select another shell. Apple’s Terminal guide

Ask zsh what the command name means

In Terminal, run whence -v with the command name, without arguments that would execute it. For example:

whence -v python3

The output identifies the kind of command zsh would use: it may report an alias, function, builtin, or external command. If it reports an alias or function, the name does not directly identify the executable that will run; the alias or function may expand to another command or run several commands. zsh documents whence as a way to report how a name would be interpreted. zsh shell builtins documentation

For a compact type label, use:

whence -w python3

If the result is function, inspect the definition with functions python3. If it is alias, inspect it with alias python3. These commands display the current shell definition; they do not execute the target. A function might call another function or external program, so follow the definition until you reach the command that does the actual work.

Find executable files in PATH

To find the file zsh would locate through PATH, even when an alias or function shadows the name, use:

whence -p python3

To list every matching PATH entry, use:

whence -pa python3

The -p option asks zsh to search PATH despite a shell-level definition, and -a reports all matches rather than only the first. The first PATH match is the executable file zsh would find for a normal external-command lookup. zsh can also show how a symbolic link resolves with whence -ps python3. zsh shell builtins documentation

The PATH list belongs to the current shell environment. See its directories with print -r -- $PATH; zsh presents its path parameter as a colon-separated value in this form. A change in PATH order can change which duplicate name is found first. Apple describes PATH as a list of directories the shell searches for commands, and notes that shell environment settings are specific to their execution context. Apple: Use environment variables in Terminal on Mac

Check how a command was invoked

A command written with a slash, such as ./python3 or /opt/tools/python3, specifies a path rather than asking the shell to search PATH for the name. The relative path ./python3 means a file in the current directory. Apple’s command-line primer explains that a name without a leading slash is relative to the current directory when used as a path, and that ./ explicitly runs a current-directory program. Apple: Command Line Primer

For a plain name such as python3, inspect both its shell type and PATH matches. For a path containing /, inspect that exact file. Quote paths containing spaces or shell metacharacters when you run them; for example, "/Applications/Tool Folder/tool". Apple’s primer documents quoting or escaping special characters in paths. This locates the invoked file without changing how the command is run.

Know what this lookup cannot prove

A lookup describes the current shell’s resolution, not every execution context. Another Terminal window can have a different PATH or shell setup, and a command may behave differently in a script, another shell, or an application launched outside Terminal. Apple notes that Terminal windows do not share shell environments. Apple: Use environment variables in Terminal on Mac

Also, finding a pathname does not by itself prove that it is the process ultimately used in every case: the file may be a symbolic link, a script that starts another program, or a launcher. whence -ps can reveal symlink resolution, but tracing a script’s further behavior requires inspecting that script or the program’s documentation. If whence -p returns no path, that name has no PATH match in this shell; it could still be an alias, function, builtin, or command available only through an explicit path.

For a routine check, run whence -v name first, inspect any alias or function, then use whence -pa name to compare executable candidates. That sequence answers both what zsh recognizes and which file its PATH search would find.

Sources