![]()
mac 安装 Iterm2
1
| brew cask install iterm2
|
查看系统内置shell
1 2 3 4 5 6 7 8 9 10
| cat /etc/shells
得到:
/bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh
|
设置 zsh 为默认shell
安装 oh-my-zsh
1 2 3
| git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
修改配色主题
1 2 3
| sudo nano ~/.zshrc
主题字段在 ZSH_THEME
|
使配置生效
语法高亮
1 2 3 4 5 6 7 8 9 10 11
| # 下载高亮插件 cd ~/.oh-my-zsh/custom/plugins git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
# 配置 plugins=( zsh-syntax-highlighting )
# 配置生效 source ~/.zshrc
|
自定义一个命令例子
1
| sh /User/minnie/demo/write_blog.sh
|
1,修改系统变量
1 2 3 4 5 6 7 8 9
|
export PATH="User/Minnie/demo:$PATH"
sh write_blog.sh
|
2,添加shebang声明
1 2 3 4 5 6 7 8
|
#!/bin/bash
write_blog.sh
|
3,去除后缀名
1 2 3 4 5 6 7
|
mv write_blog.sh write_blog
write_blog
|
4,添加alias声明
1 2 3 4 5 6 7 8
|
alias wb="write_blog"
wb
|
问题集锦
为什么不把脚本直接命名为wb, 而是使用alias
提示权限拒绝
提示找不到文件
栗子
自己的写博客脚本bk.sh
1 2 3 4 5 6 7
| #!/bin/bash
cd /Users/minnie/hexo/blog hexo new $1 code ~/hexo/blog/source/_posts/
exit
|
发布博客脚本fb.sh
1 2 3 4 5 6 7 8
| #!/bin/bash
cd /Users/minnie/hexo/blog hexo clean hexo g hexo d
exit
|