Command Line: z is installed but can't find the command

One can inspect the list of files installed by a Homebrew formula via brew list -f <formula_name>. In this case, the output should like

> brew list -f z
/usr/local/Cellar/z/1.9/etc/profile.d/z.sh
/usr/local/Cellar/z/1.9/INSTALL_RECEIPT.json
/usr/local/Cellar/z/1.9/README
/usr/local/Cellar/z/1.9/share/man/man1/z.1

Note that in this case there's no command (and not even bin), just a z.sh. This makes sense because z is a shell tool, and have to be sourced into the shell as functions to get and set the shell environment; running as an external command simply doesn't offer deep enough integration. Therefore, you have to source z.sh into your shell, probably in .bash_profile, .bashrc, or .zshrc.

Usually, Homebrew formulae that require post-installation interactions in order to be usable will have instructions listed in caveats, which will be shown post-install, or manually retrieved via brew info <formula_name>. In this case,

> brew info z
<irrelevant info omitted>
==> Caveats
For Bash or Zsh, put something like this in your $HOME/.bashrc or $HOME/.zshrc:
  . `brew --prefix`/etc/profile.d/z.sh

Of course you should take that advise with a grain of salt, and use more modern and human-readable shell syntax:

source "$(brew --prefix)/etc/profile.d/z.sh"

Or

source /usr/local/etc/profile.d/z.sh

if you know your Homebrew installation is in /usr/local.


in Mac osx with iterm2 with zsh just put:

First:

vim ~/.zshrc

and add this line (or just add z)

plugins=(
    git
    z
)

exit with

:x!

that's it.