前言:
应队友的要求,来写这篇博客
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文件。