You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
966 B
Bash
29 lines
966 B
Bash
#!/bin/bash
|
|
# pickmy.org post composer
|
|
# by: Jay/nq4t/@music_onhold
|
|
|
|
# usage: ./compose.sh [category] [title]
|
|
# example: /compose.sh blog MY AWESOME POST TITLE NO YOU DON'T NEED TO ENCLOSE IT!
|
|
# run in the root of your site files/repository
|
|
# assumes categories are directories in root
|
|
|
|
# Variables and category argument
|
|
category=$1
|
|
pd=$(date +'%Y-%m-%d')
|
|
pt=$(date +'%T')
|
|
file=blog$$.md
|
|
# Ditch the category argument
|
|
shift 1
|
|
# Read everything else as title.
|
|
title=$@
|
|
# Let's write the front matter to our temp file.
|
|
printf -- "---\ntitle: $title\nlayout: post\ndate: $pd $pt\nexcerpt_separator: <!--more-->\n---\n\n" >> $file
|
|
# Write the post in whatever editor you want.
|
|
nano + $file
|
|
# Make a lowercase copy of title.
|
|
t=${title,,}
|
|
# Move the file to category/_posts replacing spaces with hyphen
|
|
mv $file $category/_posts/$pd-${t// /-}.md
|
|
# Display some output to verify it's done.
|
|
printf "\nPost $title created in $category: $category/_posts/$pd-${t// /-}.md\n\n"
|