15

I'm a Mac Noob but generally a power Linux user. My new job handed me a fresh MacBook Pro with Lion installed.

I installed MacVim successfully using homebrew. I'd love for it to be the default app for opening certain file types. (.rb, .haml)

But when I attempt to assign MacVim as the default app in the Finder, the app is unheard of. A Spotlight search on MacVim turns up only the original .tgz file.

Yet I can run it from a command line (mvim) and pin it to the dock and run it from there.

I'm guessing something called an "alias" needs to be created, and I get the impression this is something different from a symbolic link. Indeed I have a symbolic link in my ~/Applications folder for MacVim, created there by homebrew.

How can I somehow bless MacVim to be an installed app and assign it to open certain file extensions?

4
  • 1
    Try brew link macvim. Ah wait... I also had a problem that somehow my link didn't work although it was there. You can unlink it first and link again and if that does not work, reinstall it.
    – Felix
    Oct 13, 2011 at 20:59
  • 1
    well that didn't seem to have any effect ...
    – Mojo
    Oct 14, 2011 at 15:06
  • Do the instructions for MacVim as a "regular" app work? That would eliminate any question that it could be the binary itself.
    – digitxp
    Oct 15, 2011 at 13:36
  • I had the same issue and symlink was not being picked by Spotlight. It got it resolved by switching to Alfredo(www.alfredapp.com) instead of Spotlight as Spotlight doesn't seem to pick symlink folder shortcuts. Similar thread apple.stackexchange.com/questions/23653/…
    – Arsal
    Nov 1, 2016 at 18:24

7 Answers 7

5

When you download a file from the Internet OS X marks it as "quarantined". You can see this with a Terminal command like:

 cd "wherever your app folder is" (not in the .app folder itself)
 ls -la@

One of the things you will see is that attribute called "com.apple.quarantine" is set for the MacVim.app folder (and for all files within its tree). If you start the app you will get a warning from OS X like "this app has been downloaded from the internet - do you want to proceed" and when you say yes it will un-quarantine the files in the app. You can do this manually for all files in the MacVim.app folder tree by using the Terminal command:

xattr -dr com.apple.quarantine MacVim.app

Or for just one file with the command:

xattr -d com.apple.quarantine somefile

I downloaded MacVim 7.3 and this would not work until I did the xattr -dr ... command, but as soon as I did, it started working fine from wherever it was installed. Set a file to use MacVim to open it and it also worked (using the "GetInfo" dialog box).

The location of the MacVim app is not really important. It's just that by convention, apps are usually located in the /Applications folder. This might not be true for some apps, but just for the sake of uniformity it probably is a good idea.

Sometimes there might be a reason why this isn't practical, like maybe you don't have write permission to the /Applications folder.

2
  • Bob, thank you for that beautiful answer! My brute force solution below worked, but I'd never have known about the apple quarantine.
    – Mojo
    Nov 2, 2011 at 23:42
  • Unfortunately, this did not work for me. Jun 24, 2016 at 17:59
13

I had the same issue. I moved MacVim.app to /Applications and then symlinked into the homebrew cellar directory.

mv /usr/local/Cellar/macvim/7.3-65/MacVim.app /Applications/  
ln -s /Applications/MacVim.app /usr/local/Cellar/macvim/7.3-65/
1
  • As per Mojo's comment, I also had to copy it rather than symlink it. The move/symlink enabled it in spotlight but I could no longer launch it by typing "mvim" in a terminal. Copying it to both locations fixed this.
    – optevo
    Aug 27, 2015 at 12:36
6

For those with Yosemite and MacVim from homebrew not showing up in Spotlight, using an alias works.

(Be sure to delete any MacVim that is already in /Applications.)

From the Terminal:

  1. Uninstall existing: brew uninstall macvim
  2. Install latest: brew install macvim
  3. Open directory in Finder. Ex: open /usr/local/Cellar/macvim/7.3-64
  4. In Finder, right-click on the MacVim.app icon and select "Make Alias".
  5. Copy the alias you just created to the /Applications folder.

Spotlight will index the MacVim alias.

Source: https://github.com/Homebrew/homebrew/issues/8970#issuecomment-4262695

2
  • 1
    this worked for me, but spotlight returns the app only if the search is case sensitive. no result if I search for "macvim", but returns app if search is "MacVim"
    – user34215
    Apr 17, 2015 at 11:47
  • Note that you can create an alias with a different name. In my case I made one called "vim".
    – alanning
    Apr 18, 2015 at 1:14
3

What worked for me is to copy the whole MacVim.app tree from where homebrew installed it (/usr/local/Cellar/...) to /Applications. A sym link was insufficient, and I couldn't make an "alias" that worked.

2

Installing MacVim using cask seems to make it available in Spotlight:

brew cask install macvim
1
  • 2
    This doesn't work in modern versions of brew. Cask is unknown subcommand. $ brew --version Homebrew 3.1.0 Instead use: $ brew install homebrew/cask/macvim Apr 12, 2021 at 13:49
2

Install the cask. It will install MacVim to the Applications directory and spotlight will be able to find it. Uninstall the non-cask formula before you do so.

brew uninstall macvim

brew install homebrew/cask/macvim

0

This was my setup - used homebrew to install MacVim on El Capitan and used the linkapps to add a symlink to /Applications/MacVIM.app . Unfortunately this wasn't being picked up by Spotlight. I was able to get spotlight working by creating a portion of the directory tree under MacVIM.app . Spotlight requires that the Info.plist and PkgInfo files be non-symlink files under MacVim.app/Contents . So in the end, I did the following:

    cd /Applications
    rm -rf MacVim.app
    mkdir -p MacVim.app/Contents
    cd !$
    ln -s /usr/local/opt/macvim/MacVim.app/Contents/* .
    mv Info.plist Info.plist.link
    mv PkgInfo PkgInfo.link
    cp Info.plist.link Info.plist
    cp PkgInfo.link PkgInfo

That was it. Note: when you update your MacVim using brew, you may have perform the steps:

    cd /Application/MacVim.app/Contents
    cp Info.plist.link Info.plist
    cp PkgInfo.link PkgInfo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .