最近有个想法,从MacOs迁移到Windows,虽说平时也是在这两个系统来回切换,但是体验并不好,随后在笔记本上开启了Windows Insider.

WSL2配置Clash代理

由于我使用的代理为Clash,但是好像并不能够自动完成WSL2的设置

vim ~/.bashrc

插入以下内容

export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*');
export https_proxy="http://${hostip}:7890";
export http_proxy="http://${hostip}:7890";
export all_proxy="socks5://${hostip}:7891";

安装Fish Shell

Fish Shell是我用过的Shell中最方便也是最现代化的一个终端,有着zsh的体验和bash的速度

sudo apt-get install fish
chsh -s /usr/bin/fish 

安装Oh-My-Fish

curl -L https://get.oh-my.fish | fish
omf install agnoster
ofm theme agnoster

但是到这里WSL自带的终端会出现乱码,故使用了Windows Terminal+Cascadia Code的组合

配置Windows Terminal

首先当然是安装微软最新的Cascadia Code,我这里使用的是CascadiaPL

在Windows Terminal按Ctrl+,打开配置文件,我的配置文件如下

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "fontFace": "Cascadia Code PL",
                "fontSize": 14,
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "cmd",
                "commandline": "cmd.exe",
                "fontFace": "Cascadia Code PL",
                "fontSize": 14,
                "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": true,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
                "hidden": false,
                "name": "Ubuntu-18.04",
                "source": "Windows.Terminal.Wsl",
                "fontFace": "Cascadia Code PL",
                "fontSize": 14,
                "startingDirectory": "/home/co1a"
            }
        ]
    },

    // 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": [
        {
            "command" :"closeTab",
            "keys": ["ctrl+w"]
        },
        {
            "command":"newTab",
            "keys": ["ctrl+t"]
        }
    ]
}

配置config.fish

vim .config/fish/config.fish

写入以下内容

set -x GOPATH /users/my-username/go
set -x PATH $PATH /usr/local/go/bin $GOPATH/bin

export PATH="$HOME/.cargo/bin:$PATH";
set hostip (cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*');
export https_proxy="http://$hostip:7890";
export http_proxy="http://$hostip:7890";
export all_proxy="socks5://$hostip:7891";
git config --global  http.proxy  http://$hostip:7890;
git config --global  https.proxy  http://$hostip:7890;