Using Spotlight to launch apps in macOS has greatly improved my workflow. But not all services that I use has a great macOS application like Gmail or Jira.
So I end up using their web applications.
But wouldn’t it be great to use spotlight to launch right into the web applications?
You can by using Terminal commands.
What does a Terminal command from Spotlight look like?
So you might be wondering, what is this Terminal command launching in Spotlight even look like?
Well it looks like this,
And by executing it, it’ll launch this,
Video of how to create Terminal commands for Spotlight
Here’s a video of how to create Terminal commands that you can call up from Spotlight to open web applications in macOS.
If you’d rather follow along the written instructions, start here.
Before, I show you how to create a Terminal command to be used with Spotlight, I assume that you’re fairly comfortable with the command-line and Terminal.app.
Create a new Terminal command
Create a file of the command you want to run in Spotlight. For the purposes of this article, I’ll be creating a command to launch my music service of choice–Amazon Music–so I’ll be creating a file called
In order for the file to be found in Spotlight, you’ll also need to add the
.command file extension.
So my final music file will be
music.command. You can place this file anywhere in your user’s directory.
Update file permission so that it is readable by Spotlight
In order for Spotlight to be able to read and run the command, we’ll need to update the file’s permission.
You’ll do this by running,
chmod u+x music.command
Add command to open up website of choice
Now, you’ll want to open up the file in your text editor of choice.
This is the command to type into your file,
The command above will open up the URL
https://music.amazon.com using the default browser you’ve set for macOS.
If you’re like to let’s say open up the URL specifically in Safari, this is the command you’d use,
open -a safari https://music.amazon.com
Once you’ve added the command in your file, save and exit.
Make sure Spotlight can find this file
Open your Spotlight preferences by going to System Preferences > Spotlight. Then under the Search Results tab, make sure to check the Developer option.
Your command is now available in Spotlight
Now when you call Spotlight and type in
music, you should see
music.command show up as a result. Selecting it will run the Terminal command and open the site in your browser.
Cleaning things up
When you ran the Spotlight command, you might’ve noticed that Terminal.app left behind an unwanted artifact.
What this screen indicates is that the command ran and exited. But this can be an eye sore, so we’ll have Terminal.app clean things up after a command runs.
To do this, make sure Terminal.app is in focus, then select Terminal > Preferences…. Now select the Profiles tab and then Shell tab.
Under the heading When the shell exits: you’ll want to select Close if the shell exited cleanly from the dropdown.
Now when you run your Spotlight command, you won’t get the Terminal.app artifact.