SOLVED: Place a Shortcuts Variable into a Shell Script

In Keyboard Maestro, I can ask for user input, place it into a variable, then place the variable into a Shell Script, then run the Shell Script. Can I do the same thing in Apple Shortcuts?


Indeed you can (there are a few ways), but perhaps for anyone coming here looking for an answer you could share some details about the particular approach you took?

Yes — Gladly, sorry I didn’t do this. Was just excited to figure this out.

I have a few SSDs (encrypted APFS volumes) which are attached to my Mac but stay unmounted until I need them. (I have a KBM macro which ejects them when my Mac starts up). When I want to mount one of these drives, I have a KBM macro which asks for input (password), puts this into a variable, then inserts into a Shell Script before the script is run. I wanted to duplicate this in Apple Shortcuts but wasn’t sure how to do so. I have since found the solution. Here is a screenshot of my KBM macro followed by the one in Apple Shortcuts. The yellow highlighted area shows where the variable is inserted into the Shell Script. For those who may not be familiar with this, the long string in the Shell Script (starts with 5AF4…) is the File System UUID for the SSD volume. Shout out to MacSparky (is he not on this discourse???) for the Apple Shortcuts for Mac Field Guide. If anyone has suggestions to improve these, please let me know.