前言:
應隊友的要求,來寫這篇博客
WSL是Windows下的一個子系統,相比Ubuntu,沒有可視化界面,但是運行速度相對比虛擬機上跑Ubuntu快,功能卻沒有那么齊全。
准備工具:
- 電腦系統 Windows 10
- 字體(WSL下的字體即為丑陋,在安裝完一些zsh之后會有亂碼現象)
系統的配置
打開控制面板 --> 程序 --> 啟動或關閉 Windows功能 --> 找到適用於Linux的Windows的子系統,勾選上,重啟電腦。
打開微軟商店下載 Ubuntu子系統,我下載的是 18.04STL
安裝之后打開,更新源
- 輸入命令修改sources.list文件,當然需要超級權限,所以要加sudo;
sudo vim /etc/apt/sources.list
- 在文件最前面添加以下條目;
鍵盤輸入 i 進入插入模式,將這段代碼復制進去,
之后使用 Esc,輸入:wq!
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
- 修改完成后,保存文件,然后運行下面的命令。
sudo apt-get update
sudo apt-get upgrade
安裝oh-my-zsh
- 安裝 zsh
sudo apt-get install zsh
設置默認 shell 為 zsh
chsh -s $(which zsh)
設置完成后使用下列命令檢查是否設置成功
echo $SHELL
- 安裝 oh-my-zsh
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
- 設置 agnoster 主題
打開 oh-my-zsh 配置文件
sudo vim ~/.zshrc
修改主題配色為 agnoster
ZSH_THEME="agnoster"
保存退出后,重新加載下配置文件
source ~/.zshrc
- 配置高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
重新配置
source ~/.zshrc
打開 vim 配置文件
vim ~/.vimrc
添加以下內容
colorscheme ron
:syntax on
filetype on
filetype plugin on
filetype indent on
set sts=4
set shiftwidth=4
set backspace=2
set tabstop=4
set showmode
set nu
set nohlsearch
到此基本就已經配置完成,但是終端界面會存在亂碼
解決方法,改變字體
[字體下載鏈接][字體下載鏈接]
[字體下載鏈接]: https://github.com/powerline/fonts
進行打包下載,下載后有一個壓縮包,解壓之后安裝各個文件里的ttf文件。