Back in June, I wrote a post about how I had started keeping track of certain habits. These were things I wanted to improve upon by doing every single day. I’ve done a somewhat good job of actually doing this since then. First, as I said in that post, I used an Obsidian daily note to track these habits. Obsidian, with the use of some plugins, would help me track and graph my progress.

Since then, I’ve moved away from Obsidian and switched all of my (computer-based) note-taking to Emacs. I know, I’m an Emacs fanboy now, but what can you do? Emacs is great, but it doesn’t do a lot when it comes to note taking without you putting some effort into it. I’ve been scripting like crazy to make this workflow something I can use, and I think I’m mostly there. I have a script that spawns rofi, that will let me either a) create a new daily note b) create a quick note c)edit a previously created daily or d) edit a quick note. I may add more to this script because I have other note categories, but I’ll need to get those better organized before I do that. Here’s the script if anyone wants to see it:

#!/usr/bin/env bash

DAILIES_DIR="/home/matt/mhome/Notes/Dailies"
QUICKIES_DIR="/home/matt/mhome/Notes/quicks"

mkdir -p "$DAILIES_DIR"
mkdir -p "$QUICKIES_DIR"

choice=$(echo -e "Daily Note\nPrevious Daily Notes\nQuick Note\nPrevious Quick Notes" | rofi -dmenu -p "Note Type:")

case "$choice" in
    "Daily Note")
        date_stamp=$(date +%Y-%m-%d)
        year=$(date +%Y)
        month=$(date +%m)
        mkdir -p "$DAILIES_DIR/$year/$month"
        note_file="$DAILIES_DIR/$year/$month/$date_stamp.md"

        if [ ! -f "$note_file" ]; then
            cat > "$note_file" << EOF
---
date: $(date +%Y-%m-%d)
type: daily
---

# Daily Note - $(date +%Y-%m-%d)

#### Stuff I Did Today
#### Thoughts
#### Mood
#### Things To Do Tomorrow


[ ] Blog Post
[ ] Track Calories
[ ] 2,000 Calories
[ ] Move More
[ ] Work on TLC
[ ] Work on HA 


EOF
        fi

        emacs "$note_file" &
        ;;
    "Previous Daily Notes")
        # Find all daily notes and format them for display
        previous_notes=$(find "$DAILIES_DIR" -type f -name "*.md" | sort -r | while read -r file; do
            basename "$file" .md
        done)

        if [ -z "$previous_notes" ]; then
            notify-send "No previous notes found"
            exit 0
        fi

        selected=$(echo "$previous_notes" | rofi -dmenu -p "Select Note:")

        if [ -n "$selected" ]; then
            year="${selected:0:4}"
            month="${selected:5:2}"
            selected_file="$DAILIES_DIR/$year/$month/$selected.md"

            if [ -f "$selected_file" ]; then
                emacs "$selected_file" &
            fi
        fi
        ;;
    "Quick Note")
        timestamp=$(date +%Y-%m-%d_%H-%M-%S)
        year=$(date +%Y)
        month=$(date +%m)
        mkdir -p "$QUICKIES_DIR/$year/$month"
        note_file="$QUICKIES_DIR/$year/$month/$timestamp.md"

        cat > "$note_file" << EOF
---
date: $(date +%Y-%m-%d)
time: $(date +%H:%M:%S)
type: quick
---

EOF

        emacs "$note_file" &
        ;;
    "Previous Quick Notes")
        # Find all quick notes and format them for display
        previous_quick=$(find "$QUICKIES_DIR" -type f -name "*.md" | sort -r | while read -r file; do
            basename "$file" .md
        done)

        if [ -z "$previous_quick" ]; then
            notify-send "No previous quick notes found"
            exit 0
        fi

        selected=$(echo "$previous_quick" | rofi -dmenu -p "Select Quick Note:")

        if [ -n "$selected" ]; then
            year="${selected:0:4}"
            month="${selected:5:2}"
            selected_file="$QUICKIES_DIR/$year/$month/$selected.md"

            if [ -f "$selected_file" ]; then
                emacs "$selected_file" &
            fi
        fi
        ;;
    *)
        exit 0
        ;;
esac

It’s a pretty simple script, the hardest part was the file choosing part, and I’ve done that before with my blog script. This works as I can just press a keybinding and get to my daily note. I’ve also added a keybinding directly in Emacs that will bring me to my Daily note or a quick note.

This is how I’ve been tracking my habits. I have a little pre-written template in each Daily, and I check off the habit as I do it. I’ve tried really hard to only check the box when I’ve actually been successful with the habit. I’ve been known to check things off my list without actually doing them, so I’m trying to do better with that.

Now that I have several months of data, it’s time to go to the next step. With Obsidian, I had real time graphs and stats about how I’ve been doing with the habits. I do not have that with my Emacs Daily Note Tracker Thingy (actual name), so I’m going to have to code that. Here’s what my script will do:

  • Print the number of days I’ve completed the habit
  • Print the number of days I’ve not completed the habit
  • Keep track of streaks and broken streaks
  • Keep track of the days where I don’t create a daily note.
  • Compute average number of habits kept and broken per week.

I may come up with a few more, but that’s where I’m at for now. I’d also like to keep a running database of this data, and that’s going to be the hardest part. I could do all the above with a bash script and some awk work. It’d be pretty simple to loop through the daily notes and see which habits have an x and which ones do not. But this is going to need historical data to compute the streaks. That’s going to be database work, something I’ve never done before. I’d love to store it as something less database-y, but that would get unwieldy very fast. This probably means that bash is out of the game. Maybe bash can interface with MySQL or whatever database I need to use, I don’t know. I’ll look to find out. But otherwise, I’m going to have to dust off my python or something similar. Maybe I’ll use the little bit of Rust I’ve been learning. I honestly do not know what language this will end up in. Bash is what I’m most familiar with.

It’s going to be a fun little project, though. I’m looking forward to it, because it’s not just another bash script. I’m going to have to learn something new here, and that’s always fun. Once I have the data, it will also prove to be very useful, because right now all I have is a sense of how well I’m doing. For the record, I’m doing well on the blog posts and the TLC, horrible on the Historic Alley, and mid on the rest. I hope to keep doing better, but tracking has definitely helped.