WSL
Windows Subsystem for Linux(簡稱WSL)是一個在Windows 10上能夠運行原生Linux二進制可執行文件(ELF格式)的兼容層。它是由微軟與Canonical公司合作開發,其目標是使純正的Ubuntu 14.04 “Trusty Tahr”映像能下載和解壓到用戶的本地計算機,並且映像內的工具和實用工具能在此子系統上原生運行。
可以理解為Windows下的Linux子系統
第一步
Win10設置——>windows更新與安全——>開發者選項——>勾選開發人員模式
第二步
控制面板——>程序和功能——>啟用和關閉Windows功能——>勾選適用於Linux的Windows子系統
過程中可能會提示你重啟
第三步
下載
方式一
Micerossft Store——>bash——>Ubuntu16.04(自己用的)——>安裝
方式二
通過命令下載查看官方文檔
查看是否成功 win+r 輸入bash 就可以了
win10下載Ubuntu16.04 后在win10下具體位置
在文件資源管理輸入
方式一
C:\Users\用戶名\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgsc\LocalState\rootfs
方式二
\wsl$\Ubuntu-16.04
換源
Ubuntu16.04
第一步
先備份原來的源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
第二步
修改sources.list
清除內容修改為
阿里源
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
清華源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
更新軟件列表和軟件
sudo apt update
sudo apt upgrade
更改外觀
由於 WSL 的會話窗口配色實際上取決於 CMD 屬性里顏色標簽里面的配色,默認的實在是太丑了,既沒有高亮字符也不清晰,嚴重影響開發效率。
這就需要用到一個開源的 CMD 配色工具:ColorTool
管理終端bash
通常 Linux 服務器上面默認使用的 SHELL 是 Bash。其實除了 Bash 之外,還有很多其他的 SHELL 程序,比如:ZSH、CSH、Fish 等等。
在這里不一一說明了
安裝zsh參考文檔
Hyper(包含了外觀和管理)
我個人在用的是Hyper
Hyper 是基於 Electron 的,所以它的插件、主題等等可拓展性都非常強大。幾行簡單的 Javascript、HTML、 CSS 代碼,你就可以定制自己的插件。
在Windows上它是集成在WSL上(高顏值跨平台的終端軟件)
去官網直接下載https://hyper.is
如果你是 macOS 平台,你還可以通過 Homebrew 命令來快速完成安裝
$ brew cask install hyper
Hyper 本身是支持插件系統的,在安裝擴展插件前,你需要先安裝 Hyper命令行程序。你可以點擊菜單,選擇 Plugin 選項,然后點擊 Install Hyper CLI command in PATH。
安裝插件
$ hyper i vermina
Hyper 的官方主題地址:https://hyper.is/themes
Hyper 的官方插件地址:https://hyper.is/plugins
通常在使用 WSL (Windows Subsystem for Linux) 工作時,我們希望啟動終端時就進入 WSL 的 SHELL 內部。但默認情況下我們需要在啟動終端並輸入 bash 命令后才能進入 WSL 終端。
現在,你只需打開 Hyper 設置頁面文件,從菜單 Edit -> Preferences進入,然后編輯 shell 和 shellArgs 參數即可。
修改為
shell: 'C:\\Windows\\System32\\bash.exe',
shellArgs: [],
重新打開 Hyper,你會發現默認已經進入了 Bash 終端界面了。