Featured image of post Linux/Windows终端美化

Linux/Windows终端美化

Ohhhhhhh!? My Posh~~

Oh-My-Posh终端美化

厌倦了默认的终端样式? 那我们就来搞些花里胡哨的东西

本篇文章将介绍用开源工具Oh-My-Posh来美化终端

好诶!

效果演示

这次把效果演示放在最前面= =

(生动形象,激发读者的阅读兴趣?)

美化前(Linux)

美化后(Linux)

美化前(Windows)

美化后(Windows)

安装Oh-My-Posh

Windows

打开你的终端/cmd/powershell,在其中输入

winget install JanDeDobbeleer.OhMyPosh -s winget

注意: 如果你需要美化WSL,请使用下文中的Linux安装方法= =

Linux

打开你的终端,输入

sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh
mkdir ~/.poshthemes
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
chmod u+rw ~/.poshthemes/*.omp.*
rm ~/.poshthemes/themes.zip

安装适配的字体

打开你的命令行工具,输入

oh-my-posh font install

注意:如果你是Windows用户需要以管理员身份运行命令

Windows Terminal注意事项

你需要设置Windows终端使用这个字体

按下快捷键CTRL + SHIFT + ,

这个是默认快捷键,如果你修改过按你自己修改的快捷键 :>

编辑settings.json修改以下内容

{
    "profiles":
    {
        "defaults":
        {
            "font":
            {
                "face": "字体名"
            }
        }
    }
}

切换主题

Oh-My-Posh安装完成之后会有一个默认的主题

如果不够喜欢的话可以切换其他的主题

获取主题列表

第一个方法是在终端输入

Get-PoshThemes

第二个方法就是去官网文档

换一个主题吧

Windows

打开终端,输入以下命令尝试主题

oh-my-posh init pwsh --config 主题路径/主题名.omp.json | Invoke-Expression

P.S. 如果出现报错找不到命令,请将C:\Users\用户名\AppData\Local\Programs\oh-my-posh\bin添加进环境变量

一旦确定主题就去修改$PROFILE的值

 notepad $PROFILE

写入尝试主题的那个语句

一般来说,主题路径会是C:\Users\用户名\AppData\Local\Programs\oh-my-posh\themes

重载$Profile后生效

. $PROFILE

Linux

这个时候可以说Linux yyds了

Linux修改主题起来特别容易,输入以下命令就能试用一个主题,也不会有讨厌的报错

#如果你用的bash把zsh替换成bash
eval "$(oh-my-posh init zsh --config 主题路径/主题名.omp.json)"

确定主题就去改~/.bashrc或者~/.zshrc

vi ~/.bashrc
vi ~/.zshrc

写入尝试主题的那个语句

依旧是重载后生效

exec zsh
exec bash

结语

到这里为止我们的美化就完成啦QwQ

如果大家想要更多花里胡哨的东西可以在评论区留言哦0.0

诶?之前文章评论呢?

–因为更新主题的缘故,就寄了呜呜呜

之后准备做一期云吸猫的文章,大家觉得怎样喵~~

Ref

Ref是不能少哒- -

https://ohmyposh.dev/docs/

https://img-blog.csdnimg.cn/img_convert/92fc35be4ee25257ace598cf95a6064b.png#pic_center

Licensed under CC BY-NC-SA 4.0
For a better open source community!
Built with Hugo
主题 StackJimmy 设计