Taking notes on the command line with nn

Posted: 11 Jun 2022. Last modified on 11-Jun-22.

This article will take about 1 minute to read.


I love learning new things, and when I do I take a lot of notes!

Today I’ll go over my note taking method. I have an intake script that utilizes the command line, and syncs my notes across machines with AWS S3. I also use the Obsidian note taking tool to organize these notes and create content.

The intake script

This script is for adding quick notes to the notes file. It’s nothing super fancy, but it is pretty effective. The current version looks like this:

nn.sh

#!/bin/zsh
set -euo pipefail

nn () {
    if [[ "sync" == "$*" ]]
    then
        # I'll go over this later
    elif [ -n "$*" ]
    then
        echo $(date "+%y.%m.%d.%H.%M.%S") "$@" >> ~/notes.txt
    else
        cat ~/notes.txt
    fi
}

nn "$*"

As you can see, there are 3 possible outcomes when you run the script, based on the arguments that it’s given.

  1. If there are no arguments, and nn.sh is run as-is, it will just print out the full contents of the notes file.

  2. If there are arguments, such as nn.sh bash is cool, it will append to the notes file with a timestamp, and the arguments verbatim, like:

     22.06.11.16.03.35 bash is cool
    
  3. If the argument is exactly sync, it will try to consolidate the local version of the file with a remote version of the file.