16

It was mentioned that we can execute a shell script using spotlight renaming it as "myscript.command" as described here. But is it possible to pass a parameter to the script when calling it from Spotlight?

For example:

Script myscript.command:

#!/bin/bash
echo "Parameter: $1"

On Spotlight:

myscript.command test

Output:

(...)
Parameter: test
(...)
[Process completed]
tripleee
  • 175,061
  • 34
  • 275
  • 318
Arthur Accioly
  • 801
  • 9
  • 26
  • I'm not sure that spotlight supports this. But you can write your shell script in such a way that it asks the user for input, using read or something like applescript. – rje Jul 12 '20 at 13:14
  • See here: https://superuser.com/questions/690141/run-a-shell-script-from-spotlight – mac13k Jul 18 '20 at 11:26
  • @mac13k That shows how to run a script from Spotlight without passing any parameters; but the OP already knows how to do that. – tripleee Jul 18 '20 at 13:25
  • It doesn't seem easily doable with a simple script, although you might be interested in the [Flashlight project](https://github.com/w0lfschild/Flashlight/), but one big downside is that it requires SIP to be disabled. – jcdl Jul 19 '20 at 06:09

1 Answers1

2

No, it does not seem to be possible currently.

tripleee
  • 175,061
  • 34
  • 275
  • 318