博客脚本

Published: 27 Mar 2016 Category: shell_script

前言

下午搭好blog后,发现每次发文章用markdown不说,还要写成如下样子。于是写了脚本思密达(主要是刚做好比较开心总想写点啥=。=)。

---
layout: post    
title: 博客脚本
date: 2016-03-27 20:55:08
tags: shell_script
category: shell_script
comments: true
---

脚本正文

#!/bin/bash    
if [ $# -ne 1 ]; then    
        echo "FORMAT: ./blog.sh ARTICAL_NAME"    
        exit    
fi    
cd ~/Documents/CODE/GIT_launch_platform/Hogwarts/_posts    
time=$(date +%Y-%m-%d)    
title=$time-$1.md    
touch $title    
cat > $title << EOF    
---    
layout: post    
title: $1    
date: $(date '+%Y-%m-%d %H:%M:%S')    
tags:     
category:     
comments: true    
---    


EOF    
mdcharm $title    
ls    
cd ..    
git add .    
git commit -m $title    
#xdg-open https://github.com/imagine4077/Hogwarts/tree/gh-pages/_posts/$title    
gnome-www-browser https://github.com/imagine4077/Hogwarts/tree/gh-pages/_posts    
comments powered by Disqus