376 字
2 分钟
Set up Windows Subsystem for Linux
2019-06-24

最终效果 Windows, 最好的 Linux 发行版

result

WSL set up#

  • 开启 WSL
Terminal window
# PowerShell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  • 到 MicroSoft Store 找一个发行版安装
  • wsl 初始化
Terminal window
apt update && apt upgrade -y
apt install -y git vim build-essential screenfetch
apt install -y curl netcat

Zsh#

  • 安装
Terminal window
# install zsh
sudo apt-get install zsh
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  • 将 zsh 设为默认 shell
~/.bashrc
chsh -s $(which zsh)
bash -c zsh
# ~/.zshrc
# customize
cd ~
screenfetch
  • 修改 zsh 主题,因为 agnoster 主题在 hyper 上有点问题,所以我使用了风格接近的 bullet-train
  • 更多主题可以查看这里 themes
~/.zshrc
ZSH_THEME="bullet-train"
  • 安装 zsh 插件

  • highlighting 和 autosuggestions 几乎是必装插件

Terminal window
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
~/.zshrc
plugins=(
# z
git
zsh-syntax-highlighting
zsh-autosuggestions
)
~/.zshrc
# fix wsl z
# @see https://github.com/rupa/z/issues/230
case $(uname -a) in
*Microsoft*) unsetopt BG_NICE ;;
esac

Install Powerline Fonts on Windows 10 #

  • 这一步主要是解决终端符号显示不全的问题
  • 下载 powerline/fonts
  • 使用管理员权限运行 install.ps1
  • 修改终端字体为带有 Powerline 的字体

Hyper set up#

fontSize: 12,
fontSize: 14, // 调整字体大小
copyOnSelect: false
copyOnSelect: true // 选择即复制
shell: '',
shell: 'C:\\Windows\\System32\\wsl.exe', // 默认启动 wsl
shellArgs: ['--login'],
shellArgs: [],
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
fontFamily: '"DejaVu Sans Mono for Powerline"', // 调整字体为 Pownline 的字体
plugins: [],
plugins: ['hyper-material-theme'], // 主题插件

integrate vscode#

  • 修改设置使 vscode 使用 wsl,同时修改字体为 Powerline 字体
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
"terminal.integrated.fontFamily": "Source Code Pro for Powerline"
}

Reference#

Set up Windows Subsystem for Linux
https://www.waterwater.moe/posts/2019/2019-06-24_wsl/
作者
whitewater
发布于
2019-06-24
许可协议
CC BY-NC-SA 4.0