Windows 终端美化方案:Fluent Terminal + Oh My Posh

3,399 阅读2分钟

本文正在参加「金石计划 . 瓜分6万现金大奖」

1. 效果展示

image-20221009111314547.png

2. 下载 Fluent Terminal :微软自带的应用商店(Microsoft Store)里面去搜索下载

3. 设置鼠标右键打开

(1) 点击 👉下载图标
(2) 新建后缀 .txt 文件,复制下面👇代码拷贝进去,再改后缀为 .bat
copy /y FluentTerminal.ico "%LOCALAPPDATA%\Microsoft\WindowsApps"
reg add "HKCU\Software\Classes\Directory\shell\Open Fluent Terminal here\command" /d "\"%LOCALAPPDATA%\Microsoft\WindowsApps\flute.exe\" new \"%%V\"" /f
reg add "HKCU\Software\Classes\Directory\shell\Open Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%\Microsoft\WindowsApps\FluentTerminal.ico" /f
reg add "HKCU\Software\Classes\Directory\Background\shell\Open Fluent Terminal here\command" /d "\"%LOCALAPPDATA%\Microsoft\WindowsApps\flute.exe\" new \"%%V\"" /f
reg add "HKCU\Software\Classes\Directory\Background\shell\Open Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%\Microsoft\WindowsApps\FluentTerminal.ico" /f
reg add "HKCU\Software\Classes\Drive\shell\Open Fluent Terminal here\command" /d "\"%LOCALAPPDATA%\Microsoft\WindowsApps\flute.exe\" new \"%%V\"" /f
reg add "HKCU\Software\Classes\Drive\shell\Open Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%\Microsoft\WindowsApps\FluentTerminal.ico" /f
reg add "HKCU\Software\Classes\LibraryFolder\Background\shell\Open Fluent Terminal here\command" /d "\"%LOCALAPPDATA%\Microsoft\WindowsApps\flute.exe\" new \"%%V\"" /f
reg add "HKCU\Software\Classes\LibraryFolder\Background\shell\Open Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%\Microsoft\WindowsApps\FluentTerminal.ico" /f
(3) 将下载的图标和下面的代码放在同一个文件夹,鼠标右键以管理员身份运行.bat文件,回到桌面,鼠标右键即可看到如下图所示:
image-20221116102327501

4. 使用 Oh-My-Posh 美化终端

(1) 打开电脑自带 powershell,输入指令,(github资源,耐心等待,或者科学上网😮):
winget install JanDeDobbeleer.OhMyPosh -s winget
(2) 安装完后重启下终端,输入下面指令初始化:
oh-my-posh init pwsh | Invoke-Expression
(3) 初始化后大概率会出现字体乱码,这时候需要下载官方推荐字体 Meslo LGM NF,字体安装完成后解压--全选--右键:为所有用户安装该字体
(4) 字体安装完成后,重启Fluent Terminal,设置--终端--字体,配置如下:
image-20221116103541737
(5) 上述设置完成后,还需要给 PowerShell 设置初始化脚本,使用下面指令设置:
code $profile
(6) 此时,VsCode 会打开一个空白文件,输入以下脚本并保存
oh-my-posh init pwsh --config ~/.jandedobbeleer.omp.json | Invoke-Expression
cls
(7) 回到PowellShell终端,使用管理员权限运行以下命令来允许 PowerShell 每次打开时执行初始化脚本:
set-ExecutionPolicy RemoteSigned

image-20221115231329453

5. 更改 Oh-My-Posh 主题

(1). 查看所有主题,输入指令:Get-PoshThemes,即可预览所有主题

image-20221009115728178.png

(2). 终端中输入指令 code $profile , 再次打开脚本文件,输入上一步拷贝的代码,如下:(wopian 就是我目前选择的主题)

oh-my-posh init pwsh --config 'C:\Users\Administrator\AppData\Local\Programs\oh-my-posh\themes\wopian.omp.json' | Invoke-Expression
cls

6. Fluent Terminal 设置背景图

image-20221009120432819

7. 隐藏 PowellShell 长长的提示

image-20221009120700622.png

8. VSCode中设置默认终端PowellShell 即可