背景

Hexo blog有几个常用的命令是用来测试和deploy文章的。通过设置bash alias可以少打很多字。

方法一:使用全局配置

Windows Git Bash Alias配置文件

配置文件在这里:
C:\Program Files\Git\etc\profile.d\aliases.sh

然后添加自己的alias

例如hd 就是hexo s / hexo server,用来开启本地服务用来调试博客。

1
2
3
4
5
6
7
# --show-control-chars: help showing Korean or accented characters
alias ls='ls -F --color=auto --show-control-chars'
alias ll='ls -l'

# alias for hexo blog command
alias hs='hexo clean && hexo g && hexo s'
alias hd='hexo g && hexo d && hexo b'

方法二:使用局部(用户)配置

使用命令notepad ~/.bashrc打开 或 创建用户配置文件

C:\Users\USERNAME\.bashrc

添加自定义命令alias

1
2
3
4
5
6
7
8
9
10
11
12
# ----------------------
# Git Command Aliases
# ----------------------
alias ga='git add'
alias gaa='git add .'
alias gaaa='git add --all'

# ----------------------
# WP CLI
# ----------------------
alias wpthl='wp theme list'
alias wppll='wp plugin list'

Reference