I recently installed iTerm2 and ZSH (with oh-my-zsh) after some months of very light usage of the stock Terminal on Mac OS.

I heard of a tool called "z" and installed it via brew with brew install z. I used it for one night with no problems. Later on it stopped working, saying zsh: command not found: z. I tried installing it again, and was met with Warning: z-1.8 already installed.

How does this make sense? It's installed but the command is not found? How could I go about restoring this functionality?


  • brew list -f z to see all files installed for the z formula.
    – 4ae1e1
    Nov 11, 2015 at 0:31
  • I'm sorry, but what do I do with the result of this command? How is this useful for me? Nov 11, 2015 at 0:32
  • In fact, if you run the command I gave you, you'll see that no such command as z is installed. You'll have /usr/local/Cellar/z/1.9/etc/profile.d/z.sh (or 1.8 in your case; you appear to have outdated formula definitions). You should follow the caveats sections of brew info z, which says For Bash or Zsh, put something like this in your $HOME/.bashrc or $HOME/.zshrc: . `brew --prefix`/etc/profile.d/z.sh.
    – 4ae1e1
    Nov 11, 2015 at 0:33
  • Oh, by the way you shouldn't use that obsolete syntax. Replace that brew --prefix with /usr/local, or at least wrap it in $() instead.
    – 4ae1e1
    Nov 11, 2015 at 0:35
  • Thanks! This worked for me! If you'd like to post this as an actual answer instead of a comment, I will certainly upvote and accept as the correct answer. Nov 11, 2015 at 0:52

3 Answers 3


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

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"


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

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

  • P.S. By "more modern and human-readable shell syntax" I'm comparing to the POSIX shell... Unfortunate folks writing shell-agnostic shell tools are stuck to POSIX, but the rest of us who know we're using something better don't have to conform to that.
    – 4ae1e1
    Nov 11, 2015 at 1:10

in Mac osx with iterm2 with zsh just put:


vim ~/.zshrc

and add this line (or just add z)


exit with


that's it.

  • 2
    Put it where?  Type it?  When?  Every time you login?  What does it do?    Please do not respond in comments; edit your answer to make it clearer and more complete. Feb 14, 2019 at 20:51

I believe Brew installs things in /usr/local/bin rather than /usr/bin to avoid needing root priveleges. Often this needs adding to your $PATH (the default directories to look for applications and scripts) - especially if you've changed shells. Once added you should have access to all your Brew-installed commands again.

  • Looks like it's already added. When I echo my $PATH, I get /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin, it seems like in there. Nov 10, 2015 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.