1 2

在git bash中使用oh my zsh

在git bash中使用oh my zsh

安装zsh

  1. 首先从官网下载git bash

  2. 进入MSYS2 Packages点击File下载.zst压缩包,如图所示:

    image-20220327192237548

  3. 直接解压至Git根目录下(可通过git bash的快捷方式找到根目录),使用7-Zip-zstd解压,解压后文件结构如图所示:

    image-20220327193103419

    1. 打开git bash,输入zsh,首次打开zsh会对zsh进行一些配置,默认即可,最终应该有如下的界面

      [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WVAp1M9L-1652723944119)(https://raw.githubusercontent.com/ytikewk/Blog_pics/main/image-20220327194638853.png)]

安装oh my zsh

  1. 进入官网,复制首页命令进行安装。

    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    

    安装成功后会出现oh my zsh的彩色字体

  2. 选择一些oh my zsh插件安装

    进入oh my zsh的插件文件夹

    cd ~/.oh-my-zsh/custom/plugins
    

    下载 zsh-autosuggestions和zsh-syntax-highlighting两个插件(推荐使用)

    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.git
    

    在zsh配置文件中添加plugin

    vim ~/.zshrc
    

    修改plugins行

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

    在git bash中更新zsh

    source ~/.zshrc
    

配置默认使用zsh

../Git/etc/bash.bashrc文件末尾追加以下内容:

# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi

之后每次启动/新建Git Bash,都会是zsh

参考

[一文搞定 Windows Terminal 设置与 zsh 安装【非WSL】](

posted @ 2022-07-12 20:37  啦啦啦小石头  阅读(241)  评论(0编辑  收藏  举报