Building an Alfred extension for my developer notes
If you follow the usage instructions on the alfy GitHub page, step 4 "Go to your new workflow directory" will you get you to the correct place that your code needs to be added in the Alfred workflow.
Getting there is half the battle already done.
This is how my config looks like:
Once there, run the following in a terminal to get things up and going:
As for the Alfred code itself, it was super straight forward:
That is literally it for the magic that happens with Alfred, but what is the
json I am importing?
I decided to have a script that generates the latest doc set during my Git pre-push hook from the developer notes repo.
Generating the docset list
As mentioned above, I have a helper script that will generate the
data.json file above.
That file looks like so:
The above code is not doing anything magical. It follows this process:
- Get the directory where all the docs are stored on my local developer notes repo.
- Iterate through the subdirectories, get the files and map through to make string changes that will end up matching the JSON structure that Alfy requires for the
alfy.inputMatchesfunction in my Alfred Workflow script.
- Write all that information to the
data.jsonfile in the Workflow directory.
I have omitted the paths on my local for both the developer notes directory + the Alfred workflow directory.
That's it! Everytime I make a change in the developer notes, a pre-push Git hook will generate the latest
data.json file and place it where it needs to go. Easy peasy!
Opening the URL
This last part is nice and straight forward - you just need to take the selected input from Alfred and pass it to "Open URL"!
Open at URL workflow
Now I can peruse my notes locally from wherever I want!
Searching through Alfred looks like so...
Searching on Alfred
...and selecting the document will open up my browser at the page.
Opening at the website
Resources and Further Reading
1,200+ PEOPLE ALREADY JOINED ❤️️
Get fresh posts + news direct to your inbox.
No spam. We only send you relevant content.