When I run a bash script from Spotlight, a terminal window launches to execute it. The window closes when the script finishes but I'd like to prevent that window from appearing on my desktop at all.

The script has several variants (in the same script) and much like {e,f,}grep, uses the launch name, $0, to select its options. It appends some stuff to a file and opens an editor (emacs, though that's not relevant) on the file, so rhe only window I need for interaction is the editor.

Right now, the only overhead per variant is a hard link to the script. I'd rather not use Platypus or AppleScript apps to launch it/them as then I'd need a whole package per variant. I'd just like a way for the terminal to run without showing its window.


It turned out that Spotlight doesn't index all of the hard links to a file - only one of them - so that approach fails anyway.

Symlinks don't get indexed at all, so scratch that one.

OS-X aliases get indexed but the launched instance of the target script gets started with the script's original name - it gets no information about which link launched it.

I've settled on using one bash script per variant that just launches the main script with appropriate arguments, running in the background:

$ mainscript <args> &

A terminal window running the helper script blinks on only long enough to launch the main script in the background. It's accomplishes what I need.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.