Skip to content

Instantly share code, notes, and snippets.

@spazione
Created March 13, 2016 02:25
Show Gist options
  • Save spazione/9ac08e4bc6f857c913a4 to your computer and use it in GitHub Desktop.
Save spazione/9ac08e4bc6f857c913a4 to your computer and use it in GitHub Desktop.
A simple function to create a new jekyll-post entry from terminal, insert some datas in the new file just created and then open it.
# A simple function to create a new jekyll-post entry from terminal,
# insert some datas in the new file just created and then open it.
#
# Usage : $ post "My awesome title" "categoty1 category2 category3"
function post() {
title=$1
category=$2
lowercase=$( tr '[A-Z]' '[a-z]' <<< $title)
space=${lowercase// /-}
now=$(date +%Y-%m-%d)
namefile="$now-$space.md"
touch $namefile
echo "---" >> $namefile
echo "layout: post" >> $namefile
echo "title: $title" >> $namefile
echo "category: $category" >> $namefile
echo "---" >> $namefile
echo $content >> $namefile
open $namefile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment