-
Notifications
You must be signed in to change notification settings - Fork 1
/
post
executable file
·51 lines (43 loc) · 1.29 KB
/
post
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/bash
# create post
# by hyiltiz <hyiltiz AT gmail DOT com>
# Mon May 13 10:57:23 CST 2013
# VERSION 0.1
editor=${EDITOR:-vim}
title=$(echo ${@} | sed 's/ /-/g')
file="$(date --iso)-${title}.md"
filename="_posts/${file}"
dict="/usr/share/dict/words"
if [ -f "${filename}" ]; then
# we already have the file
# just open it
echo "post found, now editing..."
${editor} ${filename} ${dict}
else
# create a new file with YAML Front Matter
# create post file
echo "Let's write something..."
touch ${filename}
git add ${filename}
# YAML Front Matter
echo "---" >> ${filename}
echo "layout: post" >> ${filename}
echo "title: ${@}" >> ${filename}
echo "categories:" >> ${filename}
echo " - Life" >> ${filename}
echo " - Software" >> ${filename}
echo " - Psysics" >> ${filename}
echo " - Psychology" >> ${filename}
echo "tags:" >> ${filename}
echo " - " >> ${filename}
echo " - " >> ${filename}
echo " - " >> ${filename}
echo "---" >> ${filename}
echo "" >> ${filename}
${editor} ${filename} ${dict}
fi
echo ""
echo "Now run the following if the post is ready to be *post*ed:"
echo "git commit -a -m \"post: ${file}\""
echo "git push"
echo ""