Skip to main content

Create New Post script

Quickly create new posts #

Made this little script to generate the front matter for new blog posts and open them in the editor. Estimated to save dozens of seconds over the course of my lifetime


#gather post info

echo "Post title?"
read title

echo "Post description?"
read description

current_date=$(date +%Y-%m-%d)

echo "Post tags? (one or more, comma separated, like, this)"
read tags

#clean up tags

tidytags=$(echo $tags | sed "s/, /\\n  - /g")

#generate post metadata

title: \"$title\"
description: \"$description\"
date: $current_date
  - $tidytags
#convert title to filename

filename=$(echo $title | tr '[:upper:]' '[:lower:]' | tr ' ' '-').md

#write metadata to filename
echo "$fmatter" > "./content/blog/$filename"

#open vim @ filename
vim "./content/blog/$filename"