Mac oh-my-zsh 配置
zsh 配置可以分为下面几个
- 主题配置
- 插件配置
- alias 配置
- 其他一些配置
主题配置
oh-my-zsh 所有的主题配置都在这里 themes。看中哪款主题,直接设置
ZSH_THEME=robbyrussell
即可。
插件设置
任何一款软件或者社区要想壮大,具有良好的拓展性是必不可少的。oh-my-zsh之所以这么流行,强大的插件支持也是一个重要的原因。 官方插件列表:oh-my-zsh Plugins。 比较常用的插件有
git
默认安装
autojump
用于自动跳转。j Downloads,就可以直接进入到对应的目录。
安装:
brew install autojump
安装完在 plugins 中配置:
plugins=(... autojump)
最后需要下面这一行到 .zshrc 中:
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
安装完后执行 source .zshrc,就完成了。
zsh-syntax-highlighting
对平常输入对命令进行高亮显示。正确显示绿色,错误显示红色。 Clone this repository in oh-my-zsh's plugins directory:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Activate the plugin in ~/.zshrc:
plugins=( [plugins...] zsh-syntax-highlighting)
Restart zsh (such as by opening a new instance of your terminal emulator).
安装完后执行 source .zshrc,就完成了。
zsh-autosuggestions
输入命令时,会自动给出建议。 Clone this repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins)
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):
plugins=(zsh-autosuggestions)
Start a new terminal session.
安装完后执行 source .zshrc,就完成了。