My New Favourite Way to Write

I love markdown. I take notes in markdown. I keep todos in markdown. I write emails in markdown and publish this blog in markdown.

The posts and pages of this blog live as markdown files in a git repository. Whenever I add or update a markdown file, the site and its static pages are rebuilt.

Here’s the problem. I want publishing to be seamless. I don’t want to think about git or committing files when adding or editing a blog post. I don’t want to switch from markdown editor to terminal or git tool. I want to write, save and see changes live on site without friction. Typically you’d do that on a publishing platform or CMS, most likely through a web interface.

How does one publish to git from a writing app? There are headless CMS solutions like Forestry that commit to a git repository and Ulysses can integrate with Medium, but I’ve ditched it.

I often collect links, thoughts, pieces of information that I’d like to include in a post. This happens throughout the day, ad hoc when I don’t have the time to organize them. The next best thing is to drop the links or notes into the place they end up in - the post itself.

I’m looking for something simple, publishing straight from the app I have always open - my notes app.

Then I found Nota.md. The developers call it Pro writing app designed for local Markdown files. What caught my attention was its Command Pallet feature — the ability to run arbitrary commands within the app.

A few niche things I’d like the app to do:

  • When the app is quit, reopen the last notes (a surprising amount of markdown editors don’t do that)
  • A seamless workflow to publish to git within the app
  • Ability to show which files are new or modified in git

Nota seemed to tick the right boxes.

Here’s how I publish with Nota.

After installing Nota, hit CMD+Shift+P and choose Create New Custom Command.

Nota Create Custom Command

This creates and opens a new file from .nota/commands/my-command.sh.

First, let’s rename the command:

mv .nota/commands/my-command.sh .nota/commands/publish-to-git.sh

Edit the content of that file with the following:

#!/bin/bash
# @parameters workspace file
cd $1 && git add $2 && git commit -m "Update via Nota" --allow-empty && git push

Here’s what this snippet does:

  1. Change directory to your Nota workspace (where your notes live)
  2. Commits the changes to the current open file
  3. Pushes the file to git

Now, whenever you have a file open, you can hit CMD+Shift+P and search for Publish to Git”.

Also - A” and M” tags in the notes list indicate whether files are new or modified in git.

Nota Publish to Git

Tada! 🎉 This is now my favourite way to write and publish to git.

Is there a tool or workflow I haven’t considered? Let me know on Twitter!


Tags
Writing

Date
July 11, 2021