Created
October 25, 2014 16:58
-
-
Save bumaociyuan/fb1a5ba9d29f22bb0709 to your computer and use it in GitHub Desktop.
自动生成blog 模板
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
#! /bin/bash | |
#cd current path | |
cd `dirname $0` | |
#get post name | |
postName=$1 | |
#split post name with '-' | |
array=(${postName//,/}) | |
printf -v var "%s-" "${array[@]}" | |
var=${var%?} | |
#get date | |
dateName=$(date +%Y-%m-%d-) | |
#create .md file | |
fileName=$dateName$var'.md' | |
touch $fileName | |
#get post time | |
postTime=$(date +%Y-%m-%d%t%H:%M:%S) | |
#write template into .md file | |
cat > $fileName << EOF | |
--- | |
layout: post | |
title: "$postName" | |
date: $postTime | |
categories: [] | |
tags: [] | |
--- | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment