WindowsTerminal + wsl2 + ubuntu + zsh配置方法

WindowsTerminal

相比传统的cmd和PowerShell,WindowsTerminal更智能且界面也更美观

wsl2

用来创建win10下的子虚拟机

  • 然后在微软自带的应用商店中找到WindowsTerminal并安装
    在windowsTerminal中可以设置默认配置文件这样打开windowsTermin就是我们的子虚拟机了

  • 在ubuntu中安装zsh
    首先需要在系统中配置git账号,之后会频繁用到git,配置方法可以参考:ubuntu配置git
    安装zsh

sudo apt update
sudo apt install git zsh -y
  • 安装oh my zsh
    直接git clone比较慢可以在~/.bashrc末尾加上一下语句:
export hostip=$(cat /etc/resolv.conf |grep nameserver | awk '{ print $2 }')
export https_proxy="http://${hostip}:1080"
export http_proxy="http://${hostip}:1080"

端口号根据自己的SSR本地端口进行对应改动(更多->选项设置)

安装oh my zsh所需的字体

git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh

返回上一级删除 fonts 文件

cd ..
rm -rf fonts

安装oh my zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • 安装历史命令自动补全
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
  • 安装高亮显示
git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

安装完改一下配置文件

vim ~/.zshrc#或者gedit ~/.zshrc

把plugins中两个刚刚下载好的插件名字加进去,然后保存退出

plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
)

最后更新一下配置文件

source .zshrc

安装成功

  • 设置zsh为默认shell
    查看zsh所在位置
whereis zsh

如果有多个值 以 xxx/bin/zsh 为准
然后:

chsh -s  xxx/bin/zsh

执行之后注销重新登陆即可

安装皮肤

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

然后设置.zshrc文件的ZSH_THEME="powerlevel10k/powerlevel10k"

卸载wsl子系统

首先查看本机安装了哪些子系统:

wsl --list --all

其次:

wsl --unregister <System_name>

到其路径下将全部文件删除即可

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容