windows中用wsl安装ubuntu配置oh-my-zsh并解决乱码问题

  • Post author:
  • Post category:其他




启用linux子系统

管理员身份打开powershell

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

然后去应用商店安装ubuntu



换源


ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

sudo vim /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse



zsh+oh-my-zsh

  1. 安装zsh

    sudo apt-get install zsh
    
  2. 把默认的Shell改成zsh

    chsh -s /bin/zsh
    
  3. 安装oh-my-zsh

    sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    

    如果访问不了github,就先下载脚本,然后把里面的仓库地址改成gitee的镜像仓库

    REMOTE=${REMOTE:-https://github.com/${REPO}.git}
    #上面这行换成
    REMOTE=${REMOTE:-https://gitee.com/mirrors/oh-my-zsh.git}
    



解决乱码问题:windows安装powerline字体

oh-my-zsh装完之后命令行会出现一些奇怪的小方块,需要在windows里面装一些字体。

git clone https://gitee.com/SpiritLing/powerline-fonts.git

在PowerShell中执行

Set-ExecutionPolicy Bypass
.\install.ps1

其中,只有DeJaVu Sans Mono for powerline字体可以正常显示字符。



版权声明:本文为liu432linux原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。