ShakeWellerer is an Alfred Workflow that allows you to setup groups of snippets with an associated trigger. Each time a snippet group is triggered, a random snippet from that group is pasted into the active application.
It can be used to add some variation to your canned ticket responses, or to quickly paste some random variation of commonly used text.
Inspired by @yamiacat's ShakeWeller, this edition focuses on flexibility, ease of use and making use of Alfred's Workflow configuration.
- Supports Emoji ✨!
- Uses the Mac OS clipboard in compliance with NSPasteboard.org to preserve clipboard history.
- Supports customization of newlines and spacing.
- Based on Swift, so it's fast and lightweight*.
*Kinda, probably doing a bit much for the task at hand.
As of Mac OS 14 Sonoma running .swift files from the commandline is proving uncooperative so the workflow has been clumsily adapted to work with a compiled Swift CLI application.
To download and install the CLI application to your bin, run the following commands in your terminal:
wget https://github.com/ausdrew/ShakeWellerer/releases/latest/download/ShakeWellerer
chmod +x ./ShakeWellerer
sudo cp -f ./ShakeWellerer /usr/local/bin/ShakeWellerer
rm ./ShakeWellerer
I'd prefer for the script to be in Alfred in full, and will add it back in when Apple fixes the issue.
Download ShakeWellerer.alfredworkflow and open it to install or update.
Snippets can be defined in the Alfred Workflow Configuration - click the 'Configure Workflow...' button.
Each snippet group can have its Extra Lines set separately. This is the number of newlines that will be added after the snippet is pasted. This is useful for getting your cursor to the next line after your snippet to continue writing, but can be turned off. Newlines and spacing within snippets are kept so you can optionally just include them in your text.
Each snippet group can have a keyword assigned that is used to trigger that snippet group.
The script imports snippets that are defined in Alfred's workflow configuration via the use of environment variables.
Alfred has some documentation on how these work:
Additional snippet groups can be added by adding more fields to the configuration builder and creating additional triggers.
- Open the 'Prepare workflow configuration and variables' window from the
$(x)$ button in the workflow window.
- On the 'Configuration Builder' tab add a new text area from the
$+$ menu
- Variable: Used later to build your trigger for this snippet group, must be unique, take note of it. e.g. SnippetGroup6
- Label: User facing name where you can edit the snippet group. e.g. Snippet Group 6
- Description: User facing description for this snippet group.
- Vertical Size: Set to large to allow for more space when editing.
- Default Value: Optional default text for snippet group contents.
- Trimming: Untick this to prevent Alfred removing newlines and whitespace.
- Validation: Use your own judgement :)
Optional: Repeat the same steps with a text field to create an additional "Extra Lines" option as well. You can also re-use an existing Extra Lines variable from another snippet group when configuring your trigger, just note it down. If no Extra Lines variable is supplied the script will default to 2.
-
Configure your snippets as desired in the regular 'Configure workflow...' window now that there are additional fields.
-
Create a new Trigger & 'Arg & Vars' block in the workflow and drag to connect it all together
- The trigger will be the text or hotkey that generates this snippet block
- The 'Arg & Vars' block tells the script which configuration/snippet group to select from
- Selector: This variable tells the script which snippet group to use, enter the Variable name you selected earlier as its value.
- ExtraLines: This variable tells the script which Extra Lines value to use, enter the variable name for this field, or an existing one, or leave it blank for the default (2).
trigger.mp4
You should now have an additional snippet group to use and configure as needed!
Given the tool's nature it's quite impractical to use from the command line but Alfred calls it like so:
extlines="${ExtraLines}"
snippets="${Selector}"
encoded_string=$(echo -n "${!snippets}" | base64)
ShakeWellerer ${!extlines} ${encoded_string}
Fortunately Alfred adds the necessary options from the configuration to the environment variables. Bash is used to convert the snippets to base64 as a lazy way of getting around potential escaping issues.