I have installed a vim using brew, and it was installed to a very different place, and now I want to locate that vim, in a shell script, is there a good approach for this?

  • brew info vim can give you the information. – cuonglm Aug 30 '15 at 17:10

You should find the newly installed vim in the bin directory under the homebrew prefix:

echo `brew --prefix`/bin/vim

Certainly brew info vim will tell you what cellar brew installed vim into. Since I haven't installed vim using homebrew, let me show you an example using wget:

benlavery@Talantinc:~ $>brew info wget
wget: stable 1.16.3, HEAD
Internet file retriever
/opt/homebrew/Cellar/wget/1.14 (8 files, 716K)
  Built from source
/opt/homebrew/Cellar/wget/1.15_1 (9 files, 908K)
  Built from source
/opt/homebrew/Cellar/wget/1.16 (9 files, 920K)
  Built from source
/opt/homebrew/Cellar/wget/1.16.1 (9 files, 940K)
  Built from source
/opt/homebrew/Cellar/wget/1.16.3 (9 files, 1.5M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/wget.rb
==> Dependencies
Build: xz ✔
Recommended: openssl ✔
Optional: libressl ✘, pcre ✘
==> Options
        Build with debug support
        Enable iri support
        Build with libressl support
        Build with pcre support
        Build without openssl support
        Install HEAD version

You can see the most recent version marked with an asterisk (*).

So for me, wget was installed into


I can now use find to search for where homebrew symlinked wget:

benlavery@Talantinc:~ $>find / -lname *Cellar/wget/1.16.3/bin/wget 

Notice I've used *Cellar/wget/1.16.3/bin/wget as the lname and not the full path. Homebrew links the files relative to their install, so if we used the full path we wouldn't have caught ../Cellar/wget/1.16.3/bin/wget.

I now know that /opt/homebrew/bin/wget is what I should use in my script.

As I said, this is using wget, the same process can be used to investigate where vim is.


If the newly installed vim is your current vim:

echo `which vim`

If you want to override system vim with brew:

brew install macvim --override-system-vim

If you want to play with paths in a script, I'd recommend reading this q/a:


  • no that won't help, because the brew install at a different place, so which vim only find a vim in /usr/local/bin – Matthewgao Aug 28 '15 at 3:08

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.