I'm looking for something which runs under macOS that will let me do the following:
Suppose I have a file called "program.list" with contents something like this:
"Program 1" "/usr/local/bin/program 1"
"Program 2" "/usr/local/bin/program 2"
"Program 3" "/usr/local/bin/other-program xyz"
"Program 4" "/usr/local/bin/something-else"
... etc. ...
I'd like to feed this file to a program which, for example, could be called "run-from-list", and which I could invoke as follows:
run-from-list program.list
… and when that command is invoked, the following would show up on the screen in a scrollable list:
Program 1
Program 2
Program 3
Program 4
... etc. ...
And whatever line I click on, the associated program will run. For example, if I click on "Program 1", it will run the "/usr/local/bin/program 1" program.
Is there any way to write "run-from-list" in MacOS without compiling source code into an executable? A scripting language would be suitable. Or is there some sort of existing utility that I could download which I could use similarly for this purpose?
Best Answer
I combined
zsh
andAppleScript
to accomplish this. Doesn't need compilation.My version of
program.list
looks like this:I created a
run_from_list.sh
in my home dir and executechmod +x run_from_list.sh
.The contents of
run_from_list.sh
are as follows. Code is adequately commented for every relevant step:Test it:
cd ~
;./run_from_list.sh program.list
.