How do I create an icon as a shortcut on MacOS to run specific shell command?
I want to create an icon (just like an Application) on my Mac and after clicking it, the Terminal app will shows up and run the command ssh -D8989 [email protected]
or any other commands.
Is there any way I can achieve it?
Thanks
Solution 1:
cat > myscript.command #!/bin/bash ssh -D8989 [email protected] ^D chmod a+x myscript.command
Explanation: You just need a text file containing your shell commands, preferably with a "shebang" line at the top telling your shell which shell you'd like it to use to execute the script. You need to mark it executable using chmod
, and you need the filename to end in .command
so Finder sees it as a double-clickable shell script to hand off to Terminal.app.