Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a shell script using Spotlight?

Is there a way to run a shell script using Spotlight on Mac OS X 10.6? I would like to be able to invoke a shell script directly from Spotlight without opening up a terminal.

like image 444
theactiveactor Avatar asked May 20 '10 20:05

theactiveactor


People also ask

How do I run a shell script on a Mac?

Instead of typing the full path, you can drag the script onto the Terminal window from Finder. Then, to execute, just enter /path/to/script . Again, you can drag and drop the file onto the Terminal window. This syntax should execute the script using the correct shell as defined on the first line of the script.


2 Answers

Save your shell script with a .command suffix - this makes it double-clickable and you should also be able to run it directly from Spotlight too.

like image 119
Paul R Avatar answered Sep 26 '22 00:09

Paul R


I would also like to add, if you need the terminal window to disappear after running the command, you can set the terminal settings to do just that.

It's under settings >> shell >> when the shell exits.

This will still leave Terminal running but the script will at least clean up after itself.

I used this for writing a script to hide and show desktop icons.

like image 24
Shaolo Avatar answered Sep 27 '22 00:09

Shaolo