45

I used brew to install MacVim and it put it in /usr/local/Cellar/macvim/7.3-61/MacVim.app

I would like to be able to go to spotlight and type MacVim to launch the app. I tried creating a symlink in the Applications directory to /usr/local/Cellar/macvim/7.3-61/MacVim.app. But that doesn't seem to show up in Spotlight. I set the executable bits on the symlink. open MacVim.app from the command line works. How can I get MacVim to show up in Spotlight search?

  • 2
    Spotlight doesen't look inside hidden folders and apparently doesen't work for aliases either. Do you use spotlight to launch apps? If so I must recomend alfredapp.com. I use it and its great. Faster than spotlight! – kevin9794 Aug 31 '11 at 2:25
  • Thanks. I installed alfred and added the MacVim folder to the search scope. Im in much better shape. – m_sharp Aug 31 '11 at 5:00
  • 3
    OK, I figured it out. If I make an alias to /usr/local/Cellar/macvim/7.3-61/MacVim.app, Spotlight will index it. For more on aliases, check out switchingtomac.com/tutorials/creating-aliases-in-mac-os-x – m_sharp Aug 31 '11 at 5:07
  • 3
    Welcome to Ask Different! If you found a solution, please post it as an answer so it's easier for others with the same problem to see what helped. Please take a look at the FAQs for more info. Thanks. – Nathan Greenstein Nov 11 '11 at 23:10
  • 1
    To clarify @m_sharps's comment, it appears that Spotlight will index aliases, but not symbolic links (ln -s). – zourtney Aug 31 '12 at 15:55
37

In the Finder, press CommandShiftG for Go to the Folder. Type /usr/local/Cellar/macvim/7.3-61/ and press return. Select the file (actually a folder) MacVim.app Press CommandL for Make Alias. Depending on permissions, you may be prompted for an administrator password here.

Press CommandN to create a New Finder Window. Press CommandShiftA to go to the Applications folder in that window.

Drag the newly created alias from the window in which it was created to the window containing the Applications folder. Rename the alias so it no longer ends in " alias".

  • 2
    I followed your steps and MacVim shows up in spotlight. However when trying to launch MacVim from spotlight, I get an error message "Item MacVim is used by OS X and can't be opened". – m_sharp Dec 12 '11 at 5:32
  • Hmmm. How do you ordinarily launch MacVim when not using Spotlight? Do you get an error message then? – Daniel Dec 12 '11 at 6:26
  • Maybe spotlight can't launch it because it doesn't have the permissions to access /usr/local/ or something. – styfle Jan 12 '12 at 4:05
  • I got this to work by first changing the permissions on /usr/local/Cellar with 'sudo chflags nohidden /usr/local/Cellar' (I actually did this for /usr /usr/local and /usr/local/Cellar). Then I used Finder to create an alias for MacVim (the one in Cellar). Then I moved the alias to my Applications folder. Spotlight now finds MacVim (look at the bottom of its list until you open it once). – Chris Oct 18 '14 at 17:32
  • I also needed to do additional permission changes, by default, it appears the symlink was created without any execute permissions at all, adding those made the symlink appear in spotlight. Oddly enough, aliases I created and then renamed to something that didn't include the word "alias" at the end also weren't picked up by spotlight. Putting "alias" back at the end of the symlink name fixed it- – chrismarx Mar 16 '15 at 14:34
6

The alias method did not work for me. A better option is to use Automator to create an Application that runs a shell script:enter image description here

Also, linking directly to the MacVim.app in the Cellar directory like some of the other answers suggest binds you to a specific version. If brew upgrades MacVim, your link will still point to the old version. Rather, you should use:

open /usr/local/opt/macvim/MacVim.app $@

as this location is automatically symlinked by brew to the most recent version.

This worked great for me. I save the Automator file in iCloud so I can conveniently add the app on other machines.

  • This seems like the most robust solution. What is the $@ for? – Jacktose Sep 13 '16 at 1:45
  • 1
    The $@ represents the arguments passed to the script. In this case, any args passed to the script are being forwarded to the MacVim.app (i.e. file names, options, etc.) See this answer about special shell variables. – zim Sep 13 '16 at 4:56
  • Ah, thanks. It's really hard to google $@. Will that actually do anything in this case, though, since the script is just being run by selecting the app? – Jacktose Sep 13 '16 at 5:08
  • 1
    Yeah, it's helpful, for example, if you use the Open with command on a file in Finder. The app will be started with the file path as the first argument. Or if you set MacVim as the default app for a file type, .txt for example - then double clicking a .txt file will start MacVim with the selected file as the first arg. – zim Sep 13 '16 at 15:14
4

The way I've solved this is using a shell script and appify.

For example make a script with a text editor that contains

#!/bin/bash

/usr/local/Cellar/macvim/7.3-61/MacVim.app

Then get appify - http://git.abackstrom.com/appify.git

Run appify on the shell script and it will make an application you can put in /Applications that will invoke MacVim. This will show up in spotlight.

  • 1
    If you're going to do it this way, just create an Automator app to run the script. – ocodo Oct 25 '14 at 14:11
  • Yes @Slomojo, that proved to be the easiest approach. I created a shellscript that starts the App (in my case libreoffice) and put it in /usr/bin. Then I used automator to just invoke the script and saved the Automator created App in my Applications folder with the name I wanted to use in Spotlight. Absurd. – atripes Jan 22 '15 at 12:42
3

To keep things nice and scriptable, you can use osascript to run a little AppleScript and create your alias automatically.

osascript <<END

  set macvim to POSIX file "/usr/local/Cellar/macvim/7.3-61/MacVim.app" 
  set applications_folder to POSIX file "/Applications"

  tell application "Finder"
    make alias file to macvim at applications_folder
  end tell

END
  • This actually worked, unlike many osascript one-liners I've found in various places. – Xander Dunn Dec 14 '14 at 10:14
  • 1
    I would recommend actually moving the MacVim app to Applications. Or installing it via brew cask. Aliases do index in spotlight, but they are ranked annoyingly low. – ocodo Dec 14 '14 at 13:01
  • Thanks. I have noticed that it's hard to get Spotlight to choose my MacVim alias. – Xander Dunn Dec 14 '14 at 21:48
2

For those who use homebrew to install macvim (totally recommended)

Run the following after install

brew linkapps macvim
  • 1
    Unfortunately, these don't show up in Spotlight. – Jacktose Sep 13 '16 at 1:16
  • but you can make an alias to the MacVim link in /Applications directory, the alias is picked up by Spotlight. – Piotr Czapla Dec 21 '16 at 21:43
  • Unfortunately 'brew linkapps' does not exist any more, and it is not replaced. – Katarzyna Apr 11 '18 at 2:49
2
  1. Symbolic links (ln -s) did not work well for me, it did not appear that Spotlight would see this as an application.

  2. Making a finder alias (as described by Daniel) worked better regarding launching from Finder, but did not when using Finder Open With..., the alias would remain grayed out.

In particular, like mentioned in other comments here, I also wanted MacVim to be available when using Open With... from Finder, but with either the symbolic link or Finder alias, MacVim would remain grayed out.

What worked for me was the simple Automator script (as zim described), with the "Run Shell Script" command. The only thing I had to do differently than what zim showed in his answer is adding the -a parameter to open:

open -a /usr/local/opt/macvim/MacVim.app $@

Without the -a, when used with "Open With...", MacVim would launch, but also the parameter filename would open with whatever its default application was -- so I would get both MacVim with empty document AND TextEdit with the file I had selected to open (rather than MacVim with my selected file opened).

The automator script can be copied or aliased to the Applications folder. I also changed my automator script's icon to MacVim's icon by copying & pasting the icon from the Finder's Get Info popups.

0

After trying several of the suggested solutions, the best thing that worked for me was to copy the app from the Homebrew Cellar to the applications directory:

cp -r /usr/local/Cellar/macvim/7.3-66/MacVim.app /Applications/

Spotlight found it instantly.

0

The simple act of installing homebrew allowed me to create a symlink to Sublime Text. Perhaps you are needing more.

Install homebrew here if you have macOS

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

and then from command line (assuming ST is installed)

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

-2

Sounds like you could do the following from the Terminal.

$ ln -s /usr/local/Cellar/macvim/7.3-61/MacVim.app /Applications

You might have to use sudo to put the symlink in the /Applications directory.

  • 3
    Spotlight treats symlinks to "system files" as system files, so they aren't listed in normal results. Aliases are though. – Lri Jan 17 '12 at 2:43
  • Any way to create an OS X alias programmatically in Bash? – Mathias Bynens Aug 16 '12 at 14:50
  • @MathiasBynens - see my answer, a little AppleScript will do it. – ocodo Oct 25 '14 at 14:09

You must log in to answer this question.

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