Created
March 13, 2016 02:25
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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