Skip to content

Instantly share code, notes, and snippets.

@calweb
Created December 16, 2015 05:56
Show Gist options
  • Save calweb/01f2de9b04c55ae91cfa to your computer and use it in GitHub Desktop.
Save calweb/01f2de9b04c55ae91cfa to your computer and use it in GitHub Desktop.
small bash script that creates a file based on the args, slugified (eg. sh new-post.sh my shiny new blog post)
#! /bin/bash
DAY_DIR=$(date +%d)
MONTH_DIR=$(date +%m)
YEAR_DIR=$(date +%Y)
SLUGIFIED="$(echo "$@" | sed -e 's/[^[:alnum:]]/-/g' \
| tr -s '-' | tr A-Z a-z)"
mkdir -p "_site/${YEAR_DIR}/${MONTH_DIR}/${DAY_DIR}"
touch "_site/${YEAR_DIR}/${MONTH_DIR}/${DAY_DIR}/${SLUGIFIED}.md"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment