I wanted to explore a bit further how a shell script might be run in a shortcut, and the shortcut included below was my most recent test. It gets information about the current app (which cannot be the Shortcuts app) and creates a list for further use in the shortcut. The Run Shell Script action will only output text, so I created a newline-separated string, which I then made into a list with the Split Text action. In the following screenshot, Safari was the active app.
Current App Info.shortcut (22.4 KB)
This looks very interesting. So, in my possible case, I would like to run an rsync shell script that does a backup. Would my active application then need to be Terminal?
Why do you need Terminal at all?
Terminal is just an application used to invoke shell commands.
Just like Shortcuts’ Run Shell Script
Just like AppleScript’s do shell script
What is it about your rsync command that makes you think you need Terminal?
Camelot, I have a number (seven all total, just different source and destination folders) of backups that use the below rsync routine, I now have them running via an Automator do shell script, but would love to transition them to a “do shell script” AppleScript. Just haven’t found a way to do that, yet. The rsync does the backup and then moves any changed/deleted files into an Archive folder. I then have an AppleScript that goes through the Archive folders and deletes any files over 90 days old.
rsync -a -b --backup-dir=/Volumes/MacBook\ Pro\ Local\ Backups/Sync\ Folders\ Local\ Backups/Local\ Documents\ Archive/Documents_$(date +\%Y-\%m-\%d) --delete /Users/homer/Documents/ /Volumes/MacBook\ Pro\ Local\ Backups/Sync\ Folders\ Local\ Backups/Local\ Documents