Axi's Blog
在 Windows 上使用 WSL 进行 Vibe CodingBlur image

前言#

绝大多数的 Coding Agent 均熟悉 Linux 的命令行环境,这主要是因为这些模型主要在 Linux 终端的命令行操作数据上进行训练,而 Linux 环境也带来了大量的开发便捷性。假如你希望一边玩游戏一边在后台挂着 claude code 便结束自己所谓忙碌的一天,那么使用 WSL 是一个毋庸置疑的首要选择。

所谓 WSL,也就是 Windows Subsystem for Linux,是 Windows 系统中的一种 Linux 子系统,它允许你在 Windows 系统中运行 Linux 应用程序,并且以一种类似 Docker 的方式运行。值得注意的是,WSL 本身并不支持 GUI 应用程序,但是目前的 WSL2 可以与 Windows 共享 GUI,也就是从 WSL 中发起的 GUI 应用可以直接显示在 Windows 系统中。

更何况大多数时候你的 TUI Agent 都只存活在命令行中。

配置#

安装 WSL#

安装 WSL 非常简单,主要的操作步骤可能是读者不希望将 WSL 安装到 C 盘从而占用空间。

wsl --install -d Ubuntu-22.04
wsl --shutdown
mkdir D:\wsl
wsl --export Ubuntu-22.04 D:\wsl\Ubuntu-2204.tar
wsl --unregister Ubuntu-22.04
wsl --import Ubuntu D:\wsl\Ubuntu-2204 D:\wsl\ubuntu-2204.tar --version 2
wsl --set-default Ubuntu
powershell

你可以设置:

notepad $env:USERPROFILE\.wslconfig
powershell
~/.wslconfig
[wsl2]
networkingMode=mirrored
txt

这个配置项的意思是,WSL 的网络模式为镜像模式,也就是 WSL 的网络与 Windows 的网络是共享的。

WSL 脚手架#

接下来可以进行一系列的脚手架安装:

sudo apt update
sudo apt install zsh tmux git
bash

安装 oh-my-zsh:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
bash
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_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
bash

修改配置文件:

~/.zshrc
plugins=(z git zsh-autosuggestions zsh-syntax-highlighting)
bash

然后可以安装 miniconda:

mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
source ~/miniconda3/bin/activate
conda init --all
bash

然后可以安装 nodejs 相关工具:

# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"

# Download and install Node.js:
nvm install 22

# Verify the Node.js version:
node -v # Should print "v22.17.1".
nvm current # Should print "v22.17.1".

# Verify npm version:
npm -v # Should print "10.9.2".

npm install -g pnpm
npm install -g bun
bash

Coding Agent#

接下来就可以安装 codex 以及 claude code 了,注意网络条件:

npm i -g @openai/codex
curl -fsSL https://claude.ai/install.sh | bash
bash

小结#

这大概就是全部内容了,希望对你有帮助。

在 Windows 上使用 WSL 进行 Vibe Coding
https://axi404.github.io/blog/wsl-coding
Author 阿汐
Published at February 15, 2026
Comment seems to stuck. Try to refresh?✨