My NaNoWriMo setup

Yes, I'm one of those guys. Honestly, I didn't plan to participate in NaNoWriMo this year, but then I realized that this is my 10th anniversary, so I feel obligated to write something anyway. Since I won the first time in 2006 using OpenOffice and Google Docs, I only managed to cough up the 50,000 Words one more time in 2012 using Scrivener. It comes with a ton of features, some I really like, others I don't need and some I don't even know about. The latter is probably due to the fact that everything is hidden in clickable menues. Bottom line is that I found the interface a bit overwhelming and distracting. I think I spent more time playing around with its features than I actually spent writing.

In an effort to simplify my computer usage, I decided to use vim this time. Of course, as a self-respecting nerd, I can't just fire up vim and start typing, so I started by googling (actually DuckDuckGoing) "vim for writers" which led me here. I wrote a vimrc just for writing (I know, but I plan to revamp my vimrc, so I kept it separate from my programming environment for the time being) and put the WordCount function I found on that page in there. This way, I can keep track of my word count while I'm writing (one of the Scrivener features I really liked). I'd like something along the lines of a progress bar for my daily writing sessions, but I'm not there yet with vimscript.

Nobody wants to wake up on November 29th to learn that his/her hard drive has crashed and the 49,980 or so words written over the course of a month have been lost. So we'll need a backup strategy. Most people use a combination of Dropbox, external hard disks and thumb drives. I'm lazy, so I don't want to put conscious effort into this. Here git and my personal webspace come in handy. The provider takes care of regular backups, so all I have to do is check in everything I've written after every session and push it to the server. Or I can write on their server via ssh and just do a check in after every writing session. This would also take care of writing on various devices without any merge hassle. Heck, I could even write on my Android phone using termux. Ok, that's probably going to be a last resort when I'm really bored, but you never know.

Taking all of this into consideration, I wrote this bash script:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/bin/bash

BASEDIR=~/.nanowrimo
NOW=$(date +"%Y-%m-%d_%H:%M:%S")
TODAY=$(date +"%Y-%m-%d")
YEAR=$(date +"%Y")

cd ${BASEDIR}
${EDITOR} ${NOW}.md
git add ${NOW}.md
git commit
session_count=$(wc -w ${NOW}.md)
today_count=$(cat ${TODAY}*.md | wc -w)
total_count=$(cat ${YEAR}*.md | wc -w)
echo "Session word count: ${session_count}"
echo "Today's word count: ${today_count}"
echo "Total word count: ${total_count}"
cd -

When I call this script, it will open a new file with the current date and time as its name suffixed with .md (I'll write in markdown) in my favourite editor. When I save and exit after churning out my words for that session, it will add that file to my git repository, have me add a commit message, commit to the repository and give me a rundown of words I wrote in that session, total word count of that particular day and total word count. Also, the structure of the resulting repository will be fine grained enough to let me create all kinds of useless statistics about my writing habits, if I desire to create them. A simple cat 2016*.md > my_nanowrimo_novel.md will give me a document I can fiddle with in pandoc once november is over. I think I'm not totally done yet, e.g. I want to automatically update my word count using the NaNoWriMo API, but I couldn't be bothered to look into that yet.