Skip to content

WSL安装及配置 #11

@bl-sun

Description

@bl-sun

WSL安装及配置

参考

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

WSL安装

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

wsl --install

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

zsh

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

# 更新 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/

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

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

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

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

miniconda

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

在终端中运行以下四条命令,快速自动的安装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 -rf ~/miniconda3/miniconda.sh

初始化miniconda

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions