Oh-My-Zsh基础使用

针对MacOS平台默认的Shell,oh-my-zsh有众多功能的增强

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
source ~/.zshrc

私有使用,国内仓库提速

1
2
3
git clone https://gitee.com/ns-cn/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc

插件安装

自动提示插件Autosuggestion安装

1
2
3
4
5
# 原版
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

# 个人私有仓库
git clone https://gitee.com/ns-cn/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

语法高亮插件syntax-highlighting安装

1
2
3
4
5
# 原版
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# 个人私有仓库
git clone https://gitee.com/ns-cn/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

其他增强

通过修改~/.zshrc配置文件,实现一些其他的增强

配置命令别名

1
2
3
4
5
6
alias zshconfig="mate ~/.zshrc"
alias ohmyzsh="mate ~/.oh-my-zsh"
alias zshconfig="vi ~/.zshrc"
alias vimconfig="vi ~/.vimrc"
alias ll="ls -l"
alias vi="vim"

启用命令纠错功能

1
ENABLE_CORRECTION="true"

配置启用oh-my-zsh插件

1
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

oh-my-zsh主题修改

可选主题参考:Themes

1
ZSH_THEME="robbyrussell"

最后应用配置source ~/.zshrc

0%