Noteplan FTS for Alfred
Noteplan full-text search for Alfred - some assembly required. Work in progress, mostly working.
n [Search phrase]- Full text search. If there isn't any note available, "Create new note" command is the only result
nn Title of the note- Creates a new note, in the folder of your choice
nref- Refresh SQLite database
- PHP install available in CLI
- SQLite with fts5 enabled (available by default in the SQLite "amalgamation" build bundled with Homebrew PHP)
- Ensure you have all the requirements (Homebrew, PHP) installed
- Clone this repository to your alfred workflows folder (or elsewhere and symlink it)
_config.php, which at minimum contains absolute path to your noteplan document root
- You can find it in Settings: Settings → Sync → [Sync method] → Advanced → Open Local Database Folder
- "root" is the folder that containes all your things - Backups, Notes, Calendar items, templates. Everything.
nrefin the Alfred to generate your sqlite cache for the first time
nrefeverytime you close the Noteplan app, or setup any kind of automation for a periodical run of the alred caching action. There are multiple options for this, and it depends on what you're the most comfortable with.
return [ 'noteplan_root' => '/absolute/path/to/noteplan/' ];
Example periodic cache refresh with Keyboard Maestro
For 500 notes, current runtime of the note import script is
~500ms, which is fast enough to have it setup to run every time Noteplan window loses its focus. This is how I have it currently setup:
Edit: I've now updated the script to run a minute after Noteplan was deactivated, with a bit of logic to cancel previous waiting runs of the keyboard maestro script, which is useful if you're transferring data between noteplan and other apps. You can find the macro to import in the
additional/ folder, just don't forget to edit the absolute path to the
run-cache-sqlite.php file in your workflow folder.
This repository also contains
ripgrepversion - databaseless version of full-text search: PHP parses input, prepares ripgrep search, and then formats the results. Available via command
nrg, which will be removed in future updates.
nodejsversion - this one is super dirty/simple testing version, where I tried if it would be possible to do the sqlite access/formatting via packaged, standalone nodejs script for users with no programming experience. It is possible, but due to requirements like codesigning (Apple Developer Program yearly licenses, etc.), will probably not be developed further. Rough testing search version available as
© 2022 Adam Kiss