21

I run commands in terminal a lot and i'm wondering if it is possible to run the commands from spotlight. For example in spotlight would like to run the command(because i have a lot of network issues):

ping google.com

And then spotlight to load terminal and execute the command instead of having to load terminal because it takes so long to load. So is this possible?

5
  • 1
    Just have Terminal open in the background at login if you don't like the load time. Apr 18, 2011 at 14:38
  • @Nathan I can't afford it RAM is limited on my machine as I only have 2GB on the machine that needs it most of the time. Im really just trying to make myself lazy. As i've already added a link from Safari to sad for typing mistakes.
    – Dean
    Apr 18, 2011 at 14:43
  • 2GB should be enough for Terminal so if it is slow to start there could be other reasons - e.g. things in your shell start up scripts e.g. .profile
    – mmmmmm
    Apr 18, 2011 at 14:56
  • No OSX has serious memory issues. Especially when you don't clean up your system regularly, I would if I had time to do this but my main machine is in use 24/7.
    – Dean
    Apr 18, 2011 at 15:36
  • 1
    Terminal uses a minuscule amount of RAM. If it's doing otherwise there's something wrong with your system. Right now it's using less than: a) a single Google Chrome tab, b) Skype, c) Adium, d) Finder. You may want to look at Visor to see if it suits your needs.
    – boehj
    May 6, 2011 at 14:40

7 Answers 7

10

Just a heads up that Alfred app now has both global hotkeys which allows you to launch apps/commands/applescripts with a key combo, as well as Terminal/Shell integration, which lets you run any Terminal command without launching Terminal.

For example, create a script to auto-shorten a URL using goo.gl then copying it to clipboard (here's how you can do that). Or launch any terminal command (e.g. ping yahoo.com) to pop up a Terminal window.

It's part of the Powerpack and is in pre-release right now, going to general availability next week :)

Vero (community gal for @alfredapp)

1
  • 8
    this is a paid only feature.. -1 b/c you gave an answer that requires $$ for a question asking for a solution that doesn't
    – abbood
    Apr 27, 2016 at 11:25
9

Not directly but write the commands you want in a shell script and save the script with a .command extension and chmod it so it is executable. This is clickable from Finder and so should work from spotlight

3
3

I use both DTerm and Alfred. DTerm is very nice for the occasional quick command or even a man page as its results window expands to fill the screen and scroll if necessary. A simple ESC dismisses the results.

http://decimus.net/DTerm/

2
2

It's not possible through Spotlight itself.

But it's possible through free applications that can also search files and launch programs, like Spotlight.

You have the almighty Quicksilver, that can also make coffee and walk the dog.

And the new player Alfred, which is quite impressive as well.

2

This is possible with Flashlight (http://flashlight.nateparrott.com/). Flashlight is an unofficial api to spotlight and offers a plugin (http://flashlight.nateparrott.com/plugin/terminal) to run terminal commands right inside spotlight.

1
  • Flashlight is no longer supported for MacOS Sierra and higher.
    – Josh
    Dec 12, 2017 at 16:12
1

You could use Raycast, it's an interface very similar to Spotlight, but it allows you to create and call (even with parameters) your own shell scripts from the search box. See more details in the docs.

Based on Dago A Carralero's answer above, I would recommend you to install Raycast and after that, install this extension. Then, head to Raycast's Preferences section and set an alias for the extension you've just installed to whatever key you want, like so:

enter image description here

Once you've set the alias, you just have to type it into the search box whenever you want to run a Terminal command.

0

You could use Raycast, it's an interface very similar to Spotlight, but it allows you to create and call (even with parameters) your own shell scripts from the search box. See more details in the docs.

You must log in to answer this question.

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