0

I have a bookmarked file that contains a simple shell script that I have saved as a script editor app. When the script app is run, it opens the app, runs the command then closes the app, taking 1-2 seconds.

My question is, are there other methods of running the shell script (must be from a file so I can bookmark it) that are faster than the current method? The command in question is:

do shell script "open https://apple.stackexchange.com"
1
  • 1
    What do you mean by a "bookmarked" file?
    – benwiggy
    Commented Dec 20, 2022 at 7:55

1 Answer 1

4

You can double-click on a 'bare' text shell script, if it has the file extension .command, and it will launch in Terminal and run.

This would need to be written in Unix shell, not AppleScript, so:

#!/bin/zsh

open https://apple.stackexchange.com

If you just want to launch a webpage, you can drag the URL from the URL bar in Safari into the Finder, and you will get a webloc file. That will open the page when double-clicked.

3
  • 1
    'webloc' file to be pedantic, but yes, by far the simplest method is to just drag from the omnibar.
    – Tetsujin
    Commented Dec 20, 2022 at 9:21
  • Thanks, this works perfectly in the code editor, though im unsure what app to default it to to run - .sh won't let me select terminal and .command lets me, but gives an access error despite having access :The file “untitled file.command” could not be executed because you do not have appropriate access privileges.:
    – SUBZ3RO
    Commented Dec 20, 2022 at 10:01
  • @SUBZ3RO You may need to ensure that the file has the executable flag set. Yes, my mistake: .sh doesn't work for Terminal.
    – benwiggy
    Commented Dec 20, 2022 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .