oh-my-zsh 安装及配置
2023-02-19 14:23:36    1252    0    0
admin

安装 zsh

ubuntu 下:

  1. sudo apt-get install zsh

mac 下:

  1. brew install zsh

后面的内容两个系统通用

安装 oh-my-zsh

shell 的类型有很多种,linux 下默认的是 bash,虽然 bash 的功能已经很强大,但对于以懒惰为美德的程序员来说,bash 的提示功能不够强大,界面也不够炫,并非理想工具。而zsh的功能极其强大,只是配置过于复杂,起初只有极客才在用。后来,有个穷极无聊的程序员可能是实在看不下去广大猿友一直只能使用单调的 bash, 于是他创建了一个名为 oh-my-zsh 的开源项目…

  1. wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh

然后给 install.sh 添加权限:

  1. chmod +x install.sh

然后执行 install.sh:./install.sh
如果发现很慢,可以修改为gitee:vim install.sh 进入编辑状态,找到以下部分:

  1. # Default settings
  2. ZSH=${ZSH:-~/.oh-my-zsh}
  3. REPO=${REPO:-ohmyzsh/ohmyzsh}
  4. REMOTE=${REMOTE:-https://github.com/${REPO}.git}
  5. BRANCH=${BRANCH:-master}

然后将中间两行改为:

  1. REPO=${REPO:-mirrors/oh-my-zsh}
  2. REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}

然后保存退出::wq
重新执行即可。

配置 zsh

  1. vim ~/.zshrc

修改主题:

  1. ZSH_THEME="robbyrussell"

改为

  1. ZSH_THEME="ys"

修改插件:

  1. plugins=(git)

改为

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

如果.bash_profile中有配置内容的话,还需要增加一行:

  1. source ~/.bash_profile

安装插件

  1. 安装 zsh-syntax-highlighting

    1. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  2. 安装 zsh-autosuggestions

    1. git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

安装完成后,重新更新配置:

  1. source .zshrc

在编辑指令的时候,对于之前使用过的指令,按→即可快速补全,非常好用。

Prev: Linux 服务管理

Next: 使用 WSL 访问宿主机的服务

1252
Table of content