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 终端界面了.
来源: http://www.bubuko.com/infodetail-3340538.html