aliquote.org

May 13, 2019

Here is a handy script to automagically create and edit a new Hugo post from a Terminal:

#!/usr/bin/env bash

set -e
cd ~/Sites/aliquote
POST="$1"
DATE=$(date '+%Y-%m-%d-%H-%M-%S')
if [ -z "$POST" ]; then
  read "Filename: " POST
fi
if [ "$POST" = "now" ]; then
    POST=$DATE
fi
hugo new "micro/$POST.md"
(
    sleep 0.2 && vim "$HOME/Sites/aliquote/content/micro/$POST.md"
)

I’ve put this in my ~/local/bin directory, which is in my $PATH.