Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The commit message isn’t great but these are a bunch of small corrections to things you’re doing the hard way.
You shouldn’t use
with input as {query}
, butwith input as argv
. With that change we shave three lines out of the script. Not only does it become simpler, it’s more robust. This is the proper way to handle multiple arguments and paths in bash and in Alfred, you don’t need to mess with IFS.The File Buffer object is extraneous. You’re using it to process multiple files but that’s not what it’s for an it isn’t necessary for that, you can just use a File Action in multiple actions like normal.
I’ve also added an External Trigger, so people can invoke the optimisation from other Workflows. This is what prompted the PR, due to https://www.alfredforum.com/topic/17804-process-screenshots-w-imageoptim/.
I’ve only updated the files, not the Workflow file itself, because GitHub wouldn’t show the modifications to that.
If you want to add auto-updating capabilities to the Workflow, I can help with that as well.