美化你的Terminal和Shell

Windows Terminal

大部分人拿到电脑的第一件事,基本上就是在图形界面上点来点去,我却很留恋DOS机上那种人和冰冷机器通过一条条指令交互的感觉。在Microsoft推出了全新的Windows Terminal后,我再也按捺不住这种冲动,开始“重用”这个小黑框。

背景美化

2025年8月19日更新:现在可以直接在终端图形化设置中调整

通过设置打开settings.json,找到profiles下的defaults,我们先开启亚克力效果。使用useAcrylicacrylicOpacity,接着使用backgroundImagebackgroundImageOpacity设置背景图片:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"defaults": 
{
"colorScheme": "Campbell",
"cursorShape": "underscore",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "Cascadia Code"
},
"useAcrylic": true,
"acrylicOpacity": 0.8,
"useAtlasEngine": true,
"backgroundImage": "C:\\Users\\cheny\\Pictures\\new.jpg",
"backgroundImageOpacity": 0.4
}

设置完成效果:

背景

oh-my-posh美化

oh-my-posh 下有一些带有图标或者特殊符号的主题,这时如果使用默认的 Consola 字体就会显示乱码,所以在配置 oh-my-posh 前,我们需要一个 Nerd Font,它为现有的字体打了一个补丁,支持了那些特殊符号,我们可以前往 https://www.nerdfonts.com/font-downloads 选择一个你喜欢的终端字体,然后下载安装就可以了,我喜欢选择了 JetBrainsMono Nerd Font。

打开https://ohmyposh.dev/,安装oh-my-posh。我使用的是scoop:

scoop install main/oh-my-poshscoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json

接下来新建一个shell的配置文件:New-Item -Path $PROFILE -Type File -Force

在文件的最后一行加入以下内容:

1
oh-my-posh init pwsh --config 你选择的主题名称 | Invoke-Expression

配置完成后如下:

配置完成

如果不想要Powershell的提示信息,可以在Windows Terminal配置文件修改为以下内容:

1
2
3
4
5
"profiles": {
"defaults": {
"commandline": "pwsh.exe -NoLogo"
}
}

在shell的配置文件最后一行加入winfetch,可以让启动更好看!

winfetch