WSL安装及配置

参考
https://codec.wang/blog/setup-wsl-for-frontend#zshoh-my-zsh

终于毕业了,然后重装了系统。需要重新部署开发环境。记起码农高天@bilibili的视频里使用的开发环境都是在WSL中的,刚好自己也重新配置一下感受一下。

WSL安装

以管理员身份打开powershell并执行以下命令

1
wsl --install

默认安装Ubuntu系统,看到有些帖子安装的arch系统不知道差别多大。
如果出现问题可以参考:https://learn.microsoft.com/zh-cn/windows/wsl/install

WSL配置

zsh

zsh 比 bash 更加强大也更好看,配合 oh-my-zsh 和相关插件,可以实现命令高亮、命令补全、git 快捷操作等等。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 更新 package
sudo apt update && sudo apt upgrade

# 安装 zsh
sudo apt install zsh -y

# 安装 oh-my-zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true

# 安装命令补全和高亮插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/g' ~/.zshrc

# 将 zsh 设置为默认的shell
chsh -s /bin/zsh

看到有很多博客推荐kitty,不知道好用不。kitty官网:https://sw.kovidgoyal.net/kitty/

lazyvim

C语言编译器

1
sudo apt-get update && sudo apt-get install build-essential

参考
https://github.com/nvim-treesitter/nvim-treesitter/wiki/Linux-Support

Neovim

1
2
3
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
sudo rm -rf /opt/nvim
sudo tar -C /opt -xzf nvim-linux64.tar.gz

添加环境变量到配置文件(~/.bashrc, ~/. zshrc, …)

1
export PATH="$PATH:/opt/nvim-linux64/bin"

参考
https://github.com/neovim/neovim/blob/master/INSTALL.md

下载字体并安装

https://www.nerdfonts.com/

安装lazyvim

1
2
3
4
5
6
7
# required
mv ~/.config/nvim{,.bak}

# optional but recommended
mv ~/.local/share/nvim{,.bak}
mv ~/.local/state/nvim{,.bak}
mv ~/.cache/nvim{,.bak}
1
git clone https://github.com/LazyVim/starter ~/.config/nvim
1
rm -rf ~/.config/nvim/.git
1
nvim

参考
https://www.lazyvim.org/installation

开发环境

Nodejs – nvm

nvm可以用于安装多个版本的node,和在多个版本中进行切换。选择它的一个原因是nodejs官网推荐(详情:https://nodejs.org/zh-cn/learn/getting-started/how-to-install-nodejs),另一个原因是微软也推荐(详情:https://learn.microsoft.com/zh-cn/windows/dev-environment/javascript/nodejs-on-wsl)。

参考
https://github.com/nvm-sh/nvm

1
2
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

将下面的代码粘贴到对应的配置文件中

1
2
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

Python – miniconda

参考
https://docs.anaconda.com/miniconda/#quick-command-line-install

在终端中运行以下四条命令,快速自动的安装miniconda

1
2
3
4
5
6
7
8
9
10
11
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 -rf ~/miniconda3/miniconda.sh
````

初始化miniconda

```bash
~/miniconda3/bin/conda init bash
~/miniconda3/bin/conda init zsh

Java – jdk