mac环境下oh-my-zsh的安装、配置与卸载

12,331 阅读1分钟

描述

oh-my-zsh是一款开款的工具,用来帮助配置、管理zsh的功能、插件、主题等的信息,让zsh使用更多方便,实用

安装

curl:

export REMOTE=https://gitee.com/imirror/ohmyzsh.git
sh -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/tools/install.sh)"

wget:

export REMOTE=https://gitee.com/imirror/ohmyzsh.git
sh -c "$(wget -O- https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/tools/install.sh)"

fetch

export REMOTE=https://gitee.com/imirror/ohmyzsh.git
sh -c "$(fetch -o - https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/tools/install.sh)"

主题配置

主题:github.com/ohmyzsh/ohm…

主题设置

  • vim ~/.zshrc
  • 修改内容:ZSH_THEME="random"
  • 执行source ~/.zshrc生效

功能增强

命令自动补全功能:zsh-autosuggestions

1.克隆代码到$ZSH_CUSTOM/plugins(默认位于~/.oh-my-zsh/custom/plugins

git clone https://gitee.com/imirror/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

2.在Oh My Zsh配置启用插件

打开~/.zshrc,找到plugins,追加zsh-autosuggestions

编辑~/.zshrc:vim ~/.zshrc

plugins=(git zsh-autosuggestions)

使配置生效:source ~/.zshrc

效果如下:

image.png 按键盘【向右移动】键自动补全

语法高亮:zsh-syntax-highlighting

1.克隆代码到$ZSH_CUSTOM/plugins(默认位于~/.oh-my-zsh/custom/plugins

git clone https://gitee.com/imirror/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

2.在Oh My Zsh配置启用插件

打开~/.zshrc,找到plugins,追加zsh-autosuggestions

编辑~/.zshrc:vim ~/.zshrc

plugins=(git zsh-autosuggestions zsh-syntax-highlighting) 使配置生效:source ~/.zshrc

卸载

进入到.oh-my-zsh/tools目录

  • cd .oh-my-zsh/tools
  • chmod +x uninstall.sh
  • ./uninstall.sh
  • rm -rif .zshrc image.png