My first Alfred workflow
A hotkey to create a bbedit note with contents of the clipboard
Here I’m attempting to write a alfred workflow work with bbedit and document the steps as I go.
ChatGPT Prompt
Tell me how to go about writing a new Alfred (macos automation tool) workflow that can read the contents of the clipboard and create a new note.
ChatGPT Response
Certainly. Here’s a brief step-by-step guide to create an Alfred workflow that reads the clipboard and creates a new note:
Install Alfred with Powerpack: Ensure you’ve installed Alfred and purchased the Powerpack, which unlocks workflows.
Create a New Workflow:
- Open Alfred’s Preferences.
- Click on the “Workflows” tab.
- Click on the
+
at the bottom and choose “Blank Workflow”. - Fill out the details (name, description, etc.) and save.
Add a Hotkey Trigger:
- Click on the
+
in the top right corner of the workflow pane. - Choose “Triggers” > “Hotkey”.
- Set your desired hotkey combination.
- Click on the
Add a ‘Run Script’ Action:
- Click on the
+
again and choose “Actions” > “Run Script”. - For language, choose
/bin/bash
and enter the script:
- Click on the
text=$(pbpaste)
osascript -e "tell application \"Notes\"
make new note at folder \"Notes\" with properties {name:\"New Note\", body:$text}
end tell"
- Connect the Hotkey to the Script:
- Drag a line from the right side of the hotkey trigger to the left side of the “Run Script” action.
- Save & Test:
- Save the workflow.
- Copy some text, activate the hotkey, and a new note should be created in the Notes app.
Done!
My tweaks
The script seems to be for the Apple Notes application, and not for bbedit, so i fixed it to via:
pbpaste | /usr/local/bin/bbedit --clean --view-top
and it works!
Notes:
- Assigned
Cmd-Shift-b
hotkey to trigger this alfred workflow. - Previously I had assigned
Cmd-Shift-n
as the hotkey under bbedit to trigger the creation of an empty note (without copying the contents of the clipboard) - But then, I had to have bbedit open to start a new note. With this workflow, the
Cmd-Shift-b
hotkey is “universal” and can start typing notes with one keystroke.
Next steps: 1. figure out how to publish this workflow on a git repo somewhere.
Conclusion
To go fast, go slow at first ;)