First: ๐ Install yt-dlp
I want to make a siri shortcut for macos which runs a terminal command in ~/Desktop with the argument which is in the clip board
Here's how you can create a Siri Shortcut on MacOS that runs a terminal command on the Desktop with the argument from your clipboard:
-
Open "Automator" (you can press โ + space and then type in "Automator" and hit enter).
-
Choose "New Document".
-
Select "Quick Action" and then choose "Workflow receives current text in any application".
-
At the top of the workflow area, adjust "Workflow receives current" from "text" to "URLs".
-
Add a new "Run Applescript" action.
-
In the "AppleScript" text box, clear the default text and put the following code instead:
on run {input, parameters} get the clipboard set theClipboard to the result set cmd to "cd ~/Desktop && " & theClipboard do shell script cmd return input end run
-
Save the Quick Action (File > Save). Call it something recognizable, like "Execute Terminal Command".
-
Open "System Preferences".
-
Go to "Keyboard".
-
Select "Shortcuts" tab.
-
In the left pane, select "Services".
-
Scroll down to find your quick action and assign it a keyboard shortcut.
This will capture the content of the clipboard, prepend it with yt-dlp
, and then execute it in your terminal. This assumes that yt-dlp is installed and accessible from your terminal. If not, you will need to install it first.
Save the Quick Action and follow the remaining steps to assign a keyboard shortcut as mentioned in my previous instructions.
Now, whenever you copy a video URL to your clipboard and use the keyboard shortcut you set up, your Mac will run the yt-dlp command on your Desktop with that URL as the argument. [!WARNING] Remember to always be careful when executing terminal commands, especially ones that you've copied from somewhere. They could possible harm your system.
This will capture the content of the clipboard, prepend it with yt-dlp
, and then execute it in your terminal. This assumes that yt-dlp is installed and accessible from your terminal. If not, you will need to install it first.
Save the Quick Action and follow the remaining steps to assign a keyboard shortcut as mentioned in my previous instructions.
Now, whenever you copy a video URL to your clipboard and use the keyboard shortcut you set up, your Mac will run the yt-dlp command on your Desktop with that URL as the argument.
[!DANGER] Again, please be careful when using terminal commands and only run commands that you trust!
Note: This specifically requires a URL to be selected when you activate the keyboard shortcut for this to work. If you still want to use URLs from the clipboard, ignore changing the workflow settings and continue to use the previous AppleScript code.