vscode + wsl + windows terminal 美化和搭建linux開(kāi)發(fā)環(huán)境

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)了


8EBJXj.jpg

在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è)置

  1. 設(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è)表

  1. win+r輸入regedit找到計(jì)算機(jī)\HKEY_CLASSES_ROOT\Directory\Background\shell
    新建項(xiàng)Terminal(名字隨便取)
8EWtR1.jpg
  1. 默認(rèn)為右鍵文本
8EWcRI.jpg
  1. Icon為圖標(biāo),值為圖標(biāo)地址,自己在官網(wǎng)找的ico

  2. 新建項(xiàng)command,在默認(rèn)下鍵入值C:\Users\niwen\AppData\Local\Microsoft\WindowsApps\wt.exe
    這里的niwen你要改為你自己電腦用戶(hù)的名稱(chēng)

  3. 將同樣配置寫(xiě)在計(jì)算機(jī)\HKEY_CLASSES_ROOT\Directory\shell下

  4. 配置windows terminal的"startingDirectory": "./"

試一試右鍵點(diǎn)擊Terminal here

8EfeTe.jpg

接入vscode

下載插件Remote - WSL

打開(kāi)setting.json配置terminal打開(kāi)方式
"terminal.integrated.shell.windows": "C:\WINDOWS\System32\wsl.exe"
現(xiàn)在試一試效果,舒服

8Ef5X6.jpg

接入code runner

現(xiàn)在你的所有包都放在wsl中,跑code runner是不行的,除非你自己又在windows上安裝一遍

只需要在setting.json中配置

    "code-runner.runInTerminal": true,
    "code-runner.terminalRoot": "/mnt/",

就完事了

結(jié)語(yǔ)

終于結(jié)束了,我是這樣配置的,如果有什么問(wèn)題歡迎提出

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容