用 VS Code 做一些有趣 ♂ 的事。

QQ截图20200306120919.png

先来一张配置好的图!

配置 WSL

适用于 Linux 的 Windows 子系统是一个为在 Windows 10 和 Windows Server 2019 上能够原生运行Linux二进制可执行文件的兼容层。 维基百科

// 把 Windows 的开发环境都卸载了,正好学习下 Linux ,还不怕折腾坏 XD ~

QQ截图20200306124543.png

控制面板 -> 程序和功能 -> 启用或关闭Windows功能 -> 勾选 适用于 Linux 的 Windows 子系统 安装完重启一下电脑。

Ubuntu 的 LTS 版本和普通版本在更新的时候到底有什么区别? 知乎

QQ截图20200306202625.png

我安装的 QQ截图20200306124720.png Ubuntu 18.04 LTS ,VS Code 需要安装 Remote - WSL

QQ截图20200306130610.png

好像默认安装了 Node 和 Git ?没太注意,如果没有的话手动安装下。

QQ图片20200306132630.png

到这里 WSL 就差不多配置完成了,点击 左下角 测试一下。

代理本机

WSL 内 clone Github 项目无问题可跳过。

1
sudo vi ~/.bashrc

添加如下内容

1
2
export http_proxy="http://localhost:1080"
export https_proxy="http://localhost:1080"

QQ截图20200307123251.png

保存,重启下 VS Code

WSL1 升级 WSL2

WSL1 升级 WSL2,WSL2 的安装说明 刘明野的博客

这个教程挺多的,需要注意的是,转换的时候把傻逼微软的杀毒软件关了。

将 WSL 移到别的盘

A full-featured utility for managing Windows Subsystem for Linux (WSL) LxRunOffline

拯救爆满的 C 盘,下载 LxRunOffline-v3.4.1-msvc.zip ,解压到本地。

此电脑/我的电脑 右键属性 -> 高级系统设置 -> 高级 -> 环境变量 -> 系统变量 -> 双击 Path

QQ截图20200321185641

添加 LxRunOffline 的路径,确定保存。

QQ截图20200321185912

输入命令对 WSL 的目录进行移动。

1
lxrunoffline m -n <WSL名称> -d <路径>

等一会就好了。

配置终端

安装 Zsh

1
sudo apt install zsh

顶部 终端 -> 新建终端 -> 选择默认ShellF1 -> Shell -> 终端:选择默认 Shell 不出意外应该就能看到 zsh 了(这也是我最喜欢 VS Code的地方,对我这种系统命令太多记不住的人来说太方便了)。

QQ截图20200306204902.png

安装 Oh My Zsh

Your terminal never felt this good before. Oh My Zsh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
xxxx% sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Cloning Oh My Zsh...
Cloning into '/Users/xxxx/.oh-my-zsh'...
remote: Counting objects: 831, done.
remote: Compressing objects: 100% (700/700), done.
remote: Total 831 (delta 14), reused 775 (delta 10), pack-reused 0
Receiving objects: 100% (831/831), 567.67 KiB | 75.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us at https://twitter.com/ohmyzsh.
p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.

配置插件

1
2
3
4
5
6
7
cd ~/.oh-my-zsh/custom/plugins

git clone https://github.com/wting/autojump.git
# https://github.com/wting/autojump

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# https://github.com/zsh-users/zsh-syntax-highlighting

配置主题

1
sudo vi ~/.zshrc

修改/添加 如下内容

1
2
3
4
5
6
7
8
9
10
11
DEFAULT_USER=$USER

ZSH_DISABLE_COMPFIX=true

ZSH_THEME="agnoster"

plugins=(
git
autojump
zsh-syntax-highlighting
)

Ctrl + Shift + ` 新建一个终端,好看~

其它

nrm —— 快速切换 NPM 源 (附带测速功能) segmentfault 思否