#! /bin/sh cd $(dirname $0) case "$1" in ""|-*) cat <&2; exit 1 Usage: $0 SLUG [TITLE] Makes a new blog page with the slug SLUG. Also uses SLUG for the page title, unless you provide TITLE. You can, of course, change this later. EOD esac SLUG="$1" TITLE="${2:-$SLUG}" YYYY="$(date +%Y)" MM="$(date +%m)" DD="$(date +%d)" slug=$(echo "$SLUG" | tr 'A-Z ' 'a-z-' | tr -d ':') dir="$YYYY/$MM-$DD-$slug" index="$dir/index.md" mkdir -p "$dir" cat <"$index" --- title: "$TITLE" date: $YYYY-$MM-$DD tags: - untagged --- EOD echo $index emacs $index