在win10(win11)搭建开发环境

本人nodejs主力开发语言,使用vim编辑器。搭建环境包括:

  1. wsl2
  2. zsh / powerlevel10k theam
  3. tmux
  4. neovim / SpaceVim
  5. nvm / nodejs
  6. Windows Terminal

安装wsl2

参考链接

先安装Windows Terminal(win11自带了),然后使用管理员身份打开 Windows Powershell,执行命令:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

然后重启电脑,重启后下载安装wsl内核。然后执行:

wsl --set-default-version 2

安装内核后即可到Microsoft Store安装Ubuntu 20.04。安装后点击打开,第一次打开会自动安装linux,输入用户名、密码。

初始化wsl2

mv /etc/apt/sources.list /etc/apt/sources.list.bak

sudo su

输入密码后,再执行:

cat > /etc/apt/sources.list <<EOF
# 中科大 @see https://www.cnblogs.com/leeyazhou/p/12976814.html
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
EOF

exit

然后把系统更新一下:

sudo apt update
sudo apt upgrade

安装一些基础库:

sudo apt install automake build-essential pkg-config libevent-dev ncurses-dev bison

配置文件

# 我的配置文件整理在GitHub
cd ~
mkdir Applications workspace
cd Applications/
git clone git@git.zhlh6.cn:ilaipi/dotfiles.git

git仓库地址

安装zsh / oh-my-zsh

sudo apt install zsh

# 这里如果下载不了,那就到windows打开浏览器,手动下载脚本,到wsl中执行脚本即可
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

cd ~/Applications/dotfiles/
# 安装zsh的主题powerlevel10k并完成配置
sh -x install.sh

ln -sf $PWD/Applications/dotfiles/wsl/zshrc .zshrc

source .zshrc

网络代理

在Windows上开启v2ray代理。

cd ~
# proxy.sh 好像必须在zsh下能成功
ln -s $PWD/Applications/dotfiles/wsl/proxy.sh ./.proxy.sh
source ./.zshrc

测试代理:

./.proxy.sh test

# 输出即表示成功:
Current proxy: http://172.29.208.1:10809

安装nvm&nodejs

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

# 安装自己使用的node版本
nvm install v12.16.1

安装tmux

cd ~/Applications
git clone git@git.zhlh6.cn:tmux/tmux.git --depth=1

cd tmux
sh autogen.sh
./configure && make

cd ..
ln -s $PWD/dotfiles/tmux/tmux.conf ~/.tmux.conf

# 需要先clone下来tpm包管理器才能安装其它插件
git clone git@git.zhlh6.cn:tmux-plugins/tpm.git ~/.tmux/plugins/tpm

# 输入tmux 回车  进入tmux
# 然后按  ctrl+a 再按  I (shift+i)

安装Neovim

sudo apt install rustc

# neovim
sudo apt install neovim python3-neovim python3-pip ttf-mscorefonts-installer fontconfig

pip3 install pynvim

安装 SpaceVim

curl -sLf https://spacevim.org/install.sh | bash

npm i --registry=https://registry.npm.taobao.org -g vue-language-server \
      vscode-css-languageserver-bin \
      javascript-typescript-langserver \
      bash-language-server \
      typescript-language-server \
      vscode-html-languageserver-bin import-js

# 打开nvim
nvim

退出nvim,然后执行:

cd ~
rm -fr .SpaceVim.d
ln -sf $PWD/Applications/dotfiles/SpaceVim .SpaceVim.d

# 再次打开nvim 安装插件
nvim
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next