Skip to content

Instantly share code, notes, and snippets.

@cirocosta
Created October 26, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cirocosta/f706baa09c9de0ab91ba2456694fc461 to your computer and use it in GitHub Desktop.
Save cirocosta/f706baa09c9de0ab91ba2456694fc461 to your computer and use it in GitHub Desktop.
no-execuses blogging πŸ˜…
#!/bin/bash
set -o errexit
set -o xtrace
readonly dir=/Users/cirocosta/cirocosta/blog/content/notes
main() {
case $1 in
-l | --list)
ls $dir | cat
exit 0
;;
*)
blog_note $1
;;
esac
}
blog_note() {
local date=$(date +"%Y-%m-%d")
local filename=${1:-$date}.md
pushd $dir
if [[ ! -f "$filename" ]]; then
cat <<EOT >> $filename
---
title: $date
slug: $date
image: notes.png
date: $date
lastmod: $date
tags: []
categories: []
keywords: []
draft: false
---
EOT
fi
vim $filename
git add --all && git ci -m "note" && git push origin HEAD
popd
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment