Oh-My-Zsh命令行插件
- 安装HomeBrew
依赖
Xcode Commend Line
如果此时你还没有安装homebrew的话,安装homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 安装 iTerm2
命令行插件不是说,只有iterm2才提示的,Mac自带的terminal.
只是说我喜欢用iterms2而已
一般我都是直接去这里下载:
https://www.iterm2.com
命令行运行:
brew install iterm2
- 安装 Oh-My-Zsh
安装
命令行运行:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
卸载的时候调用uninstall.sh即可
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/uninstall.sh)"
更改主体:
vim ~/.zshrc
# 一般我都用这个amuse主体,会显示当前分支和命令执行时间.
ZSH_THEME="amuse"
解决路径中字体混乱:
# 下载
git clone https://github.com/powerline/fonts.git
# 安装 如果要卸载,当前目录下有uninstall.sh 给755权限后即可执行
cd fonts
./install.sh
# 删除安装包
cd ..
rm -rf fonts
# 最后然后打开Items2-->Preferences-->Profiles-->Text-->Font选中power结尾的字体即可
# 记住选择的时候看列表里面带*的才是启用的,默认是default
- 配置命令行语法高亮
# 安装高亮插件
brew install zsh-syntax-highlighting
# 将安装完毕的提示写入 source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
vim ~/.zshrc
- 官方插件
# 添加插件(不要太多要不然加载起来会很慢)
vim ~/.zshrc
# 多个插件按空格分开,这里的git自动补全git branch 时会进入一个类似linux中more命令的界面,需要q退出.
# git 该插件添加了许多别名 https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git
# command-not-found 命令不存在的时候, 使用相关命令建议包名
# autojump 扩展到频繁使用的目录,具体查看 autojump --help
# redis-cli Redis命令自动补全
# screen 是screen的界面更加丰富
# cp 带进度条的复制
# colorize cat出来的东西带语法高亮显示支持
plugins=(git command-not-found autojump redis-cli screen cp colorize)
# 如果需要在当前shell中生效
source ~/.zshrc
# 官方插件一览表
https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins-Overview
使用zsh替换bash
# 记住这个需要重启才能生效
$ chsh -s `which zsh`
# or
$ sudo usermod -s /bin/zsh username