vscode + wsl + windows terminal 美化和搭建linux開(kāi)發(fā)環(huán)境
沒(méi)錢(qián)買(mǎi)mac,windwos下命令行挺難用的,之前一直用cmder還不錯(cuò),但后期卡卡的,改用了windows terminal,真香啊,速度和外觀都不錯(cuò),剛好最近在學(xué)linux,一直用的ali云做測(cè)試,想著統(tǒng)一一下包管理和命令行,發(fā)現(xiàn)了wsl這個(gè)東西,就打算改造一下windows,個(gè)人電腦系統(tǒng)為windwos 10 1909,詳細(xì)操作如下:
1. 開(kāi)啟wsl、安裝linux
被這個(gè)坑慘了,windows版本更新不上,一直勾選不了,后來(lái)下了補(bǔ)丁,打開(kāi)windows功能一片空白,我服了,唉,最后只有重裝系統(tǒng)了
在windwos商店安裝ubuntu或者其他liunx
2. 配置ubuntu
下載完ubuntu,會(huì)設(shè)置用戶(hù)名和密碼,輸入密碼時(shí)shell上并不可見(jiàn),這里不用擔(dān)心。
替換下載源為阿里源
sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt-get update
sudo apt-get upgade
安裝zsh窃款、oh-my-zsh來(lái)美化bash
sudo apt install zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
下載node、n啄清、git、yarn俺孙、nrm辣卒、yrm
略
配置windows terminal
打開(kāi)windows terminal設(shè)置
- 設(shè)置defaultProfile即默認(rèn)打開(kāi)的terminal
{
"$schema": "https://aka.ms/terminal-profiles-schema",
// "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"copyOnSelect": true,
"profiles": {
"defaults": {
// Put settings here that you want to apply to all profiles
"startingDirectory": "./",
"useAcrylic": true,
"acrylicOpacity": 0.8
},
"list": [{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"useAcrylic": true
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}
系統(tǒng)級(jí)右鍵菜單,寫(xiě)入注冊(cè)表
-
win+r
輸入regedit找到計(jì)算機(jī)\HKEY_CLASSES_ROOT\Directory\Background\shell
新建項(xiàng)Terminal
(名字隨便取)
-
默認(rèn)
為右鍵文本
Icon
為圖標(biāo),值為圖標(biāo)地址,自己在官網(wǎng)找的ico新建項(xiàng)command,在默認(rèn)下鍵入值
C:\Users\niwen\AppData\Local\Microsoft\WindowsApps\wt.exe
這里的niwen你要改為你自己電腦用戶(hù)的名稱(chēng)將同樣配置寫(xiě)在計(jì)算機(jī)\HKEY_CLASSES_ROOT\Directory\shell下
配置windows terminal的
"startingDirectory": "./"
試一試右鍵點(diǎn)擊Terminal here
接入vscode
下載插件Remote - WSL
打開(kāi)setting.json
配置terminal打開(kāi)方式
"terminal.integrated.shell.windows": "C:\WINDOWS\System32\wsl.exe"
現(xiàn)在試一試效果,舒服
接入code runner
現(xiàn)在你的所有包都放在wsl中,跑code runner是不行的,除非你自己又在windows上安裝一遍
只需要在setting.json
中配置
"code-runner.runInTerminal": true,
"code-runner.terminalRoot": "/mnt/",
就完事了
結(jié)語(yǔ)
終于結(jié)束了,我是這樣配置的,如果有什么問(wèn)題歡迎提出