Picture of Michael Lee
:wave: Hey hey, I'm Michael Lee and this is my site about being a developer, being a dad and making side projects.

ntbk: a simple, command-line journal

Written on May 27, 2016

Ever since I became a father, I’ve done my best to capture as much of the memories that I share with my kids as possible. I’ve got gigs upon gigs worth of photos and videos, with them backed up several times over. I want to cherish these moments because ever since their arrival, life flies by in a blur.

I’ve always been bad about staying consistent with a journal, but one of the things I’ve been having the desire to do more of nowadays are writing down snippets of my every day life with my family. Snippets like conversations that I have with my 2-year-old or new milestones that my baby is starting to hit.

I’ve got numerous Moleskine notebooks, but they aren’t very portable in my opinion and I’ve tried Day One, but I wanted something much simpler, faster and free at recording my entries. Since most of my day is spent in front of the command-line, I thought I’d start there.

What I was looking for was a simple command-line tool that:

  • Made it super simple to create an entry of a moment
  • Creates or adds entries to a simple text file
  • The file(s) could be easily saved to Dropbox for backup reasons and portability

I did a quick Google search and actually came across an existing tool called jrnl. I installed it and fell in love with it. All you had to do was type jrnl and then your entry, hit enter and boom, my entry was appended to a file on Dropbox.

Upon looking at the repository, I noticed that it wasn’t updated for several months. Feeling the itch I wondered if I could create a similar tool in Node.js. I had never written a command-line tool in Node.js so another Google search and I found this excellent tutorial on building command-line tools with Node.js by Atlassian.

I’ve never programmed in Python so I didn’t actually bother to read any of jrnl’s source. Instead I just kept running jrnl over and over again in the command-line to learn how it handled user input and imagine how I could come up with something similar. A few nights of hacking, a sprinkling of emojis and I have what I’m calling version 0.1.0 of ntbk that does a few of the things jrnl does.

After you install ntbk with npm install -g ntbk the first time you run ntbk it’ll ask you where you would like to store your entries. If you leave the prompt blank, it’ll save it into a file called notebook.txt in your home directory (I designated a file on Dropbox for backup and portability purposes). Immediately after, you’ll get another prompt telling you write your first entry. Every subsequent call to ntbk afterwards will add the entries to the file you had designated.

If you’re like me and want a simple way to capture your thoughts and moments throughout your day from the command-line give ntbk a shot. If you like it or think something could be done better let me know on Twitter @michaelsoolee! Or better yet, create a pull request or an issue on the GitHub repo.

Thanks for taking the time to read this article. I'd love to stay in touch and share more tips on programming and design and side projects. Sign up and I'll send you my articles straight to your email.