自用的hexo快捷批处理

原创的Hexo快捷操作批处理,用了一段时间还算顺手,发出来共享。
目前版本0.4 ,欢迎反馈扩展和修正。

使用方法:

  1. 修改代码中相应的变量
  2. 保存成bat后缀放入hexo博客根目录,快捷方式‘blog’放入path环境变量找得到的地方。
  3. win+r 敲入相应blog命令。

示例:

blog … 打开hexo命令行

blog n test1 … 新建text1.md后用subl(sublime打开)

blog e test1 … 编辑test1.md文件

blog d … hexo d -g 编译部署后打开预览

blog r test1 … 删除test1.md

blog f … 打开_posts目录

blog i … 打开图床

代码

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@ECHO off
title hexo
PUSHD %~DP0
@rem hexo 快捷脚本
@rem 版本:0.4
@rem 作者:tuzhis
@rem 示例:
@rem >blog ... 打开hexo命令行
@rem >blog n test1 ... 新建text1.md后用subl(sublime打开)
@rem >blog e test1 ... 编辑test1.md文件
@rem >blog d ... hexo d -g 编译部署后打开预览
@rem >blog r test1 ... 删除test1.md
@rem >blog f ... 打开_posts目录
@rem >blog i ... 打开图床

@rem 博客地址
set site=http://tuzhis.github.io

@rem 浏览器路径
set browser="D:\Program Files\greenSoft\Chrome\Chrome\chrome.exe"

@rem 图床地址
set imgsite=https://portal.qiniu.com/

if "%1"=="" (
start "hexo"
Goto Exit
)

if "%1"=="n" Goto New

if "%1"=="e" Goto Edit

if "%1"=="d" Goto Deploy

if "%1"=="r" Goto Remove

if "%1"=="f" Goto Folder

if "%1"=="i" Goto Image

:New
cmd /c hexo n %2
Goto Edit

:Deploy
cmd /c hexo d -g
start " " %browser% %site%
Goto Exit

:Edit
subl source\_posts\%2.md
Goto Exit

:Remove
del source\_posts\%2*
Goto Exit

:Folder
explorer source\_posts\
Goto Exit

:Image
start "hexo" %browser% %imgsite%
Goto Exit

:Exit
Popd