可以自動 deploy hexo 並 push source code
在 root 編寫檔案,此處檔名為 hexo
(shell 可不需副檔名)
hexo1 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
| #!/usr/bin/env bash if [ "$1" == "" ]; then echo "Usage: `basename $0` [deploy|push] [comment]" echo "[comment] should use double quotes" exit 0 fi if [ $1 == "deploy" ]; then echo "deploy start:" hexo clean hexo generate hexo deploy fi if [ $1 != "" ]; then if [ "$2" != "" ]; then echo "push start:" git add . git commit -m "$2" git push fi fi
|
Usage
1 2 3 4
| $ ./hexo deploy "give some comment" $ ./hexo push "give some comment"
|
"$2"
只要用雙引號刮起來就可以吃含有空格的句子
也可以自訂別名讓指令縮短
1 2
| $ alias hd="${HOME}/hexo deploy"
|
延伸閱讀:為指令自訂別名(alias)