2021-05-26 21:06:17 +00:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2021-06-01 09:07:12 +00:00
|
|
|
(( $# < 1 )) && {
|
|
|
|
print -- "usage: ${0:t} title"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2021-05-26 21:06:17 +00:00
|
|
|
postsdir=src/posts
|
|
|
|
title="$*"
|
|
|
|
scrub=$(echo "$title" | tr '[:upper:]' '[:lower:]' | perl -pe 's/[^a-z0-9_]+/-/g;s/-+$//')
|
|
|
|
|
|
|
|
lastnumber () {
|
|
|
|
for d in "$postsdir"/*; do
|
|
|
|
number=$(echo "${d:t}" | sed 's/-.*$//')
|
|
|
|
echo "$number"
|
|
|
|
done | sort -n | tail -n 1
|
|
|
|
}
|
|
|
|
|
|
|
|
n=$(lastnumber)
|
|
|
|
newdir=$(printf "%04d-%s" $((n+1)) "$scrub")
|
|
|
|
dst="$postsdir/$newdir/index.org"
|
|
|
|
today=$(date +"[%Y-%m-%d %a]")
|
|
|
|
|
|
|
|
mkdir "${dst:h}"
|
|
|
|
cat > "$dst" <<EOF
|
|
|
|
#+title: $title
|
|
|
|
#+description:
|
|
|
|
#+keywords: blog static
|
|
|
|
#+author: Yann Esposito
|
|
|
|
#+email: yann@esposito.host
|
|
|
|
#+date: $today
|
|
|
|
#+lang: en
|
|
|
|
#+options: auto-id:t
|
|
|
|
#+startup: showeverything
|
|
|
|
|
|
|
|
EOF
|