Skip to content

Auto Habits

Akshay edited this page Jul 19, 2020 · 4 revisions

dijo supports auto-trackable habits, that is, habits that can be updated via scripts. Add an auto-habit to, say, track your git commits:

:add-auto commits 5

You can control dijo externally by calling it with the -c flag:

dijo -c "track-up commits"   # a +1 on today's count
dijo -c "track-down commits" # a -1 on today's count

Firstly, point git to your hooks directory (~/.hooks in this case):

# contents of ~/.gitconfig

[core]
hooksPath = "/home/<username>/.hooks"

Create a file called post-commit in the ~/.hooks directory, with the following contents (you should run mkdir ~/.hooks if it doesn't exist):

#! /usr/bin/env bash

dijo -c "track-up commits"
# make the post-commit script an executable

chmod +x ~/.hooks/post-commit

Voilà! Every time you make a commit, dijo will automatically track it under the commits habit.