WSL2 安装

  • 打开 Windows 自带的 Power Shell

file

  • 运行 wsl --install 默认会安装一个较新版本的 Ubuntu

file

Terminal 配置

Terminal 推荐使用 Tabby Termianl 感觉是 Windows 下颜值和功能性都比较不错的产品

推荐添加一个 WSL Ubuntu Root 用户的配置便于后续使用

file

推荐安装 oh my zsh 并配置插件使用:

  • 打开 WSL Ubuntu Root 连接,进入到 WSL Ubuntu 的 root 用户下,以下步骤中提及的命令直接运行即可

  • 确保 Git 和 ZSH 已经正确安装 apt install git zsh -y

  • 安装 oh my zsh(下文方法使用清华的镜像源安装,如果网络畅通也可以直接使用官方方案从 Github 拉取 sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

    • git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
    • cd ohmyzsh/tools
    • REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh
  • 安装 zsh 插件

    • 安装 p10k 主题 git clone --depth=1 https://gitclone.com/github.com/romkatv/powerlevel10k ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

    • 安装自动补全插件 git clone https://gitclone.com/github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

    • 安装代码高亮插件 git clone https://gitclone.com/github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

    • vim ~/.zshrc 编辑 .zshrc 文件,修改 ZSH_THEMEplugins 配置

      • ZSH_THEME="powerlevel10k/powerlevel10k

        file

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

        file

    • source ~/.zshrc 加载更改后的配置

  • 最终效果参考

    file

References