今天試裝之前為了研究 linux 系統 而有小玩的 windows wsl 系統,這次嘗試,是因為在公司mac 上玩了 alacritty 這個新的終端工具,想基於他的跨平台性能,iterm 2 以下安裝為非乾淨的 windows 安裝,有一些指令,可能會稍微有誤差
使用管理員執行 Powershell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
安裝 Ubuntu 18.04 url
sudo apt-get update
sudo apt-get upgrade
Install and configure a terminal
Alacritty
windows 底下 alacritty 的 複製貼上為 Ctrl + Shift + c, Ctrl + Shift + v
choco install alacritty
To use WSL, go to %APPDATA%\alacritty\alacritty.yml, and set to use bash shell:
shell:
program: "C:\\Windows\\System32\\wsl.exe"
Install zsh, oh-my-zsh, and nice themes and fonts
Install zsh and oh my zsh
sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Switch to use ZSH by default (nano ~/.bashrc):
我這邊設定好之後,開啟 alacritty 的情況會發生閃退,我這邊直覺地想到 可能是預設 wsl 的系統問題,於是
$ wsl -l -v
NAME STATE VERSION
* docker-desktop Running 2
docker-desktop-data Running 2
Ubuntu-18.04 Running 2
可以看到我之前安裝的 windows docker 被設定為預設的 wsl ,這邊去手動更改
# 打這段不知道為什麼無效
$ wsl --set-default Ubuntu-18.04
$ wsl -l -v
NAME STATE VERSION
* docker-desktop Running 2
docker-desktop-data Running 2
Ubuntu-18.04 Running 2
用下面的指令才生效
$ wslconfig /setdefault Ubuntu-18.04
NAME STATE VERSION
* Ubuntu-18.04 Running 2
docker-desktop-data Running 2
docker-desktop Running 2
Pure theme
一開始選擇用 npm 安裝,但是 pure 安裝的目錄不在 ~/.zsh/pure 底下,所以後面選擇用 manually 安裝
Manually Clone this repo somewhere. Here we'll use $HOME/.zsh/pure.
mkdir -p "$HOME/.zsh"
git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure"
Add the path of the cloned repo to $fpath in $HOME/.zshrc.
# .zshrc
fpath+=$HOME/.zsh/pure
字體安裝
這邊選擇 跟 mac 一樣的字體,我覺得 Source code pro 是 command line 最好的字體,這邊是nerd-fonts 因為 vim 跟 tmux 等等裡面的一些圖案,要安裝 nerd font 版本,才會顯示出來,正常的版本是沒有的, windows 版本
Source Code Pro
https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/SourceCodePro
Nerd Fonts
https://github.com/ryanoasis/nerd-fonts
Nord color
https://www.nordtheme.com/
env:
TERM: xterm-256color
window:
position:
x: 0
y: 0
padding:
x: 0
y: 0
dynamic_padding: true
shell:
# program: /bin/zsh
program: "C:\\Windows\\System32\\wsl.exe"
args:
# - -c
# - -l
- "tmux attach || tmux"
font:
# Normal (roman) font face
normal:
family: SauceCodePro NF
style: Regular
colors:
primary:
background: '0x2E3440'
foreground: '0xD8DEE9'
# Normal colors
normal:
black: '0x3B4252'
red: '0xBF616A'
green: '0xA3BE8C'
yellow: '0xEBCB8B'
blue: '0x81A1C1'
magenta: '0xB48EAD'
cyan: '0x88C0D0'
white: '0xE5E9F0'
# Bright colors
bright:
black: '0x4C566A'
red: '0xBF616A'
green: '0xA3BE8C'
yellow: '0xEBCB8B'
blue: '0x81A1C1'
magenta: '0xB48EAD'
cyan: '0x8FBCBB'
white: '0xECEFF4'
# Bright colors
bright:
black: '#3B4251'
red: '#BF6069'
green: '#A3BE8B'
yellow: '#EACB8A'
blue: '#81A1C1'
magenta: '#B48DAC'
cyan: '#8FBCBB'
white: '#ECEEF4'
tmux
https://github.com/tmux-plugins/tpm
Install Dev Tools
Node and npm
Install nodenv
curl -fsSL https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-installer | bash
Setup nodenv path (nano ~/.zshrc):
這邊如果不做設定的話,會使用到 windows choco 套件的 npm,這時候就會出現權限不足等等的問題
export PATH="$HOME/.nodenv/bin:$PATH"
eval "$(nodenv init -)"
Install node and update npm after reloading terminal (source ~/.zshrc)
nodenv install 10.16.1
nodenv global 10.16.1
npm install -g npm@latest
neovim
vim-plug
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
打開 vim 之後發現,visual line 沒有顏色,所以下面要修改
if (has("termguicolors"))
set termguicolors
endif
color nord
# ~/.tmux.conf
# $TERM, fix colors
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*256col*:Tc"
.zshrc
export LANG="zh_TW.UTF-8"
export LC_ALL="zh_TW.UTF-8"
出現錯誤
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
修正
sudo locale-gen zh_TW.UTF-8
ssh
https://devblogs.microsoft.com/commandline/sharing-ssh-keys-between-windows-and-wsl-2/