Created
October 26, 2019 19:54
-
-
Save cirocosta/f706baa09c9de0ab91ba2456694fc461 to your computer and use it in GitHub Desktop.
no-execuses blogging π
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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