Git Bash 安装 zsh 和 on-my-zsh

ref: (https://dominikrys.com/posts/zsh-in-git-bash-on-windows/)

1. 安装 zsh

https://packages.msys2.org/package/zsh?repo=msys&variant=x86_64

  • 1.1 从 MSYS2 下载 zsh package

    1
    aria2c -c -s 8 -x 8 https://mirror.msys2.org/msys/x86_64/zsh-5.8-5-x86_64.pkg.tar.zst
  • 1.2 解压
    压缩文件的格式是ZST, 需要安装一个支持的解压软件

    1
    2
    3
    scoop install zstd

    zstd -d zsh-5.8-5-x86_64.pkg.tar.zst

    \etc\usr 文件夹解压到本机 git 的安装目录:

  • 1.3 运行

    1
    2
    3
    4
    5
    zsh

    autoload -U zsh-newuser-install
    zsh-newuser-install -f

  • 设置 zsh 自启动, 在~/.bashrc加入:

    1
    2
    3
    if [ -t 1 ]; then
    exec zsh
    fi

2. 安装 oh-my-zsh

  • 下载安装

    1
    2
    3
    4
    $ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

    # gitee 镜像
    $ sh -c "$(wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh -O -)"
  • 简单配置一下,打开配置文件 nano ~/.zshrc

    1
    2
    3
    4
    5
    # 主题
    ZSH_THEME="ys"

    # 插件
    plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
  • 下载插件

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

    git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  • 加载配置文件, source ~/.zshrc