Zsh和bash一样,是一种Unix shell,大多数Linux发行版/Unix系统 都默认使用bash shell。
Zsh有强大的功能,比如补全历史命令,补全参数,选择光标补全,各种主题,强大的拓展等等,是程序员的必备工具。

光有zsh还不够,我们会使用oh-my-zsh来自动化配置zsh。
项目地址:https://github.com/robbyrussell/oh-my-zsh

安装zsh

Debian系:

1
apt install zsh

MAC:

1
brew install zsh

如果没有brew,输入以下命令安装brew:

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

切换shell:

1
chsh -s /bin/zsh

安装配置工具 oh-my-zsh

  1. 一条命令安装
    使用curl
    1
    $ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

或者使用wget

1
$ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

如果国内机器拉取github上面的代码有困难时,可以考虑使用 proxychains工具来为git加速。

  1. 半自动安装
    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
    chsh -s /bin/zsh

墙裂推荐的拓展

zsh-syntax-highlighting

  1. 安装

    1
    git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
  2. 启用拓展
    在~/.zshrc中的找到plugins关键字

    1
    plugins=(zsh-syntax-highlighting)

在plugins的括号中添加拓展名,即可启用拓展

zsh-autosuggestions

  1. 安装

    1
    git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
  2. 启用拓展
    在~/.zshrc中的找到plugins关键字

    1
    plugins=(zsh-autosuggestions)

在plugins的括号中添加拓展名,即可启用拓展

参考:https://github.com/robbyrussell/oh-my-zsh