众所周知,hexo 的一键三连和 git 命令的一键三连又臭又长 , 我们懒得敲命令

如何简化?那就使用 makefile. 因为 makefilevscode 中也有支持,而我正好一直用 vscodemarkdown, 于是,我们使用 vscode+makefile 的方式简化操作.

在博客根目录新建文档叫 makefile, 写入如下

makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
default:
@echo.
@echo "enter : 'p' or 'g' for git push, 'h' for hexo command"
@echo.

g:
git add .
git commit -m"auto commit"
git push

h:
hexo cl
hexo g
hexo s

此时,我们只需要使用 make h 命令就可以实现 hexo 的一键三连,使用 make g 就可以实现 git 的一键三连.

PS: h 或者 g 都是可以自定义的,命令内容也是可以自定义的,想改而不懂 makefile 的可以自行百度一下.

另外,新建博客时使用 hexo n page -p dir/name.md 命令可以快速创建文章 (参考自这里)

但是我还没找到和 makefile 交互实现用户输入的方法 (终究还是菜了), 等以后学到了再完善