-
-
Notifications
You must be signed in to change notification settings - Fork 91
Hooks
Hooks allow you to register commands and script to run when doing performs certain actions. You can register the following events:
-
post_config
-- Runs after the configuration is read, including any local.doingrc
file located at run time -
post_read
-- Runs after the contents of the doing file are parsed -
post_write
-- Runs after the contents of the doing file are changed. Does not run unless a modification is made
To register a hook, simply place a Ruby file in your plugins folder. This folder is located at ~/.config/doing/plugins
by default, but you can specify another location in your config using the plugin_path
key.
The ruby file should contain a call to register the hook. Pass a block to perform when the associated event is triggered.
The following runs a shell script called after_doing.sh
whenever a change is made to the doing file (post_write
event):
# frozen_string_literal: true
Doing::Hooks.register :post_write do |filename|
res = `/bin/bash ~/scripts/after_doing.sh`.strip
Doing.logger.debug('Hooks:', res)
end
That's all there is to it. As an example, I use the above shell script to update my iTerm status bar and my Touch Bar (BetterTouchTool widget) with my current task whenever the file changes. Any time I add or complete an entry, my status bars update.