WSL2安装配置
安装 WSL2
- 启用适用于 Linux 的 Windows 子系统
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- 启用虚拟化
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- 启动 Hyper-V
Windows+R 键,调出运行,键入 control,进入控制面板,进入程序,打开启动或关闭 Windows 功能,勾选 Hyper-V,重启
设置 WSL 默认版本
wsl --set-default-version 2
安装 Linux
打开 Store 商店,输入 Arch,下载
下载完了,打开,输入用户名,密码
配置 Arch
换源
切换 Arch linux、Arch linux CN 源
sudo pacman -Syyuu
sudo pacman-key --lsign-key "farseerfc@archlinux.org"
sudo pacman -S archlinuxcn-keyring
sudo pacman -S yay
sudo passwd root # 修改 root 密码
下载 nvim、zsh & ohmyzsh、yay
cat /etc/shells # 查看 zsh 是否安装
sudo pacman -S zsh
git clone --depth=1 git@github.com:ryanoasis/nerd-fonts.git
cd nerd-fonts
./install.sh
zsh & ohmyzsh
ohmyzsh 安装:
- 把 oh-my-zsh 项目 Clone 下来:
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
- 复制 .zshrc
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
- 更改你的默认 Shell
chsh -s /bin/zsh
zsh 插件:
-
powerlevel10k(主题)
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
把. zshrc 打开,找到 ZSH_THEME,把值改为 "powerlevel10k/powerlevel10k"
-
auto-suggestion(自动补全)
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
把. zshrc 打开,找到 plugins=(git),在 git 后面添加 zsh-autosuggestions
-
syntax highlighting(语法高亮)
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
把
.zshrc
打开,找到plugins=(git)
,在git
后面添加zsh-syntax-highlighting
最后 source ~/.zshrc
nvim
sudo pacman -S neovim
git clone git@github.com:ayamir/nvimdots.git
cd nvimdots/scripts
./install.sh
# 如果始终无法安装成功,则执行下条命令
rm -fr ~/.local/share/nvim/site/lazy
nano 编辑器
Ctrl+O
: 保存,按 回车 保存当前文件
Ctrl+X
: 退出
迁移 WSL2
wsl --shutdown #关闭所有正在运行的实例
wsl -l -v #查看 STATE 是否为 Stopped
wsl --export Ubuntu D:\Ubuntu_WSL2\Ubuntu.tar #导出 Ubuntu 到 D 盘的 Ubuntu_WSL2 目录并创建一个 Ubuntu.tar 的归档文件
wsl --unregister Ubuntu #注销 Ubuntu
wsl --import Ubuntu D:\Ubuntu_WSL2 D:\Ubuntu_WSL2\Ubuntu.tar #把 Ubuntu.tar 重新注册为 linux 发行版
Ubuntu config --default-user chpw #新建一个叫 chpw 用户