1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-23 12:52:10 +00:00

Archetypes and automation for composing notes

Create a shell script for composing a note/reply more quickly, including
launching the default $EDITOR
This commit is contained in:
Rohan Kumar 2022-06-02 22:03:23 -07:00
parent 734fc16df4
commit be86ab3ac7
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
3 changed files with 69 additions and 1 deletions

View file

@ -1,5 +1,5 @@
---
title: "{{ replace .Name "-" " " | title }}"
title: "{{ .Name | humanize }}"
date: {{ .Date }}
draft: true
---

10
archetypes/reply.md Normal file
View file

@ -0,0 +1,10 @@
---
title: "{{ .Name | humanize }}"
date: {{ .Date }}
replyURI: ""
replyTitle: ""
replyType: ""
replyAuthor: ""
replyAuthorURI: ""
---

58
scripts/bin/hugo-new-note Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/env dash
set -e -u
# the name of this program
progname="$(basename "${0}")"
help_text="Usage: ${progname} [OPTION...] FILENAME
Compose a new note
Options:
-h Print this help and exit
-r Whether this note should be a reply
"
usage() {
printf '%s' "${help_text}"
}
# when the user passess bad args, send a msg to stderr and exit
# usage: bad_option <option> <reason>
bad_option() {
echo "${progname}: option ${1}: ${2}" >&2
usage >&2
exit 1
}
reply='0'
while getopts "hr" flags; do
case ${flags} in
h)
usage
exit 0
;;
r)
reply='1'
shift
;;
*)
bad_option "${flags}" 'invalid option'
exit 1
;;
esac
done
filename="notes/$1.md"
if [ "$reply" = '1' ]; then
hugo new --kind reply "$filename"
else
hugo new "$filename"
fi
"${EDITOR-nvim}" "content/$filename"
# vi:ft=sh