0

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
1

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
https://www.gnu.org/software/wget/
/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
--with-debug
        Build with debug support
--with-iri
        Enable iri support
--with-libressl
        Build with libressl support
--with-pcre
        Build with pcre support
--without-openssl
        Build without openssl support
--HEAD
        Install HEAD version

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

So for me, wget was installed into

/opt/homebrew/Cellar/wget/1.16.3/bin/wget

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

benlavery@Talantinc:~ $>find / -lname *Cellar/wget/1.16.3/bin/wget 
/opt/homebrew/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.

0

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:

https://stackoverflow.com/questions/21694327/installing-vim-with-homebrew

  • 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.