Shell Script for Creating Markdown Templates

Image of Author
March 14, 2022 (last updated October 24, 2022)
  • The below script assumes a directory called repo inside of which is a folder called ./content/ which contains arbitrary markdown content.

  • The markdown file is prepended with yaml, in between the --- syntax.

  • After creating the file it is immediately opened in vim.

    nn "New Note" new-note
function nn() {
  cd ~/w/g/repo
  local filename="./content/$"
  local datestring="$(date +%F)"
  touch $filename
  cat << DELIMIT > $filename
title: $1
slug: $2
published: $datestring
updated: $datestring

# $1


  vim $filename