When using octopress to write articles. You need run commands like this. 1. rake new_post[‘name’] //to post an article 2. rake generate //to create the html files 3. rake deploy //to push your articles
When I use Ubuntu 12.04, even I need add bundle exec
to fix the gem version problem.
Cause I am in China, to fix the TimeZone problem, I need to add TZ=CCT
So before you write your article, you have already write TZ=CCT bundle exec rake new_post......
And when change my os to Ubunt Gnome, I found an article about using octopress easily.
Here is it. An Chinese coder’s article on oschina blog.
This man write an shell script to write octopress articles more easily.
I found it is really useful.
Here is the code.
#!/bin/sh
root=/my/blog/path
scriptName=`basename $0`
cd $root
case $1 in
'blog')
name=`date +"%H-%M-%S"`
if [[ $2 ]]; then
name=`echo $2|sed 's/ /-/g'`
fi
path=`rake new_post[$name]|awk -F":" '{print $2}'`
vi $path
;;
'page')
if [[ ! $2 ]]; then
echo 'need page name'
exit
fi
name=`echo $2|sed 's/ /-/g'`
echo $name
path=`rake new_page[$name]|awk -F":" '{print $2}'`
vi $path
;;
'view')
rake preview
;;
'publish')
rake gen_deploy
;;
'build')
rake clean
rake generate
;;
'open')
open $root
;;
'edit')
vi $root
;;
*)
echo "usage: $scriptName [blog|page|view|publish|build|open|edit]"
exit 1
;;
esac
Unfortunately, I found a bug when you write an article with article name.
It showed not found [[
or somethin \g like this.
And this shell use blog page build … comands, it is more difficult than new_post new_page generate
So I changed the commands name to post page preview deploy generate open edit
And add 2 commands gen_pre gen_dep
And change generate to generate not gen_deploy
And this is github link
The Original Link: http://baham.github.io/03_10_octopress-easypost-tool.html
If you want to reprint it, please do under the CC BY-NC-SA 4.0