终端美化:Windows11 下 安装 WSL 并使用好看的的 zsh 主题

310 阅读1分钟

前言

在 mac 上使用 spaceship 主题习惯了,想着看看 windows 上能不能使用

效果预览

在这里插入图片描述

步骤

在 powershell 中安装 wsl,大概等了五分钟左右,安装过程的提示很少,一度以为卡死了

在这里插入图片描述 之后重启,可以看到菜单中多了几个东西

在这里插入图片描述

打开 vscode 看一下

在这里插入图片描述

因为是新下载的 linux 环境,所以什么都没有,连个 node 都没有,要自己安装 在这里插入图片描述 我这里先安装一个 nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

魔法要开 Tun 模式,进度条才有可能往前走

下载完成后提示

root@DESKTOP-H78LOHG:/mnt/e/Study/react-learn# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15037  100 15037    0     0  45111      0 --:--:-- --:--:-- --:--:-- 45020
=> nvm is already installed in /root/.nvm, trying to update using git
=> => Compressing and cleaning up git repository

=> nvm source string already in /root/.bashrc
=> bash_completion source string already in /root/.bashrc
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:

D:\Program Files\nvm\v22.13.1
├── @antfu/ni@23.3.1
├── corepack@0.30.0
├── eslint@9.34.0
└── pnpm@10.15.0
=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:

     $ nvm use system
     $ npm uninstall -g a_module

=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
root@DESKTOP-H78LOHG:/mnt/e/Study/react-learn#

没啥大病,重启一下终端就行

在这里插入图片描述

然后安装 node

在这里插入图片描述 安装 zsh

sudo apt update
sudo apt install -y zsh

在这里插入图片描述

在这里插入图片描述 切换默认的 shell 为 zsh

 chsh -s $(which zsh)

然后安装 ohmyzsh,一个 zsh 的主题管理工具

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

在这里插入图片描述

然后克隆 spaceship-prompt.sh/getting-sta… 的主题文件

之后是编辑一下 zshrc

vim ~/.zshrc

在这里插入图片描述

在这里插入图片描述 ok 已经安装好了

然后在重启一个新的终端,应该能看到熟悉的样式了

在这里插入图片描述

还可以加一些快捷命令

在这里插入图片描述

好看的主题就完成了

在这里插入图片描述