栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

终端美化方案 FluentTerminal + oh-my-posh

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

终端美化方案 FluentTerminal + oh-my-posh

简介

研究了很久的 windows 平台的终端方案,最终得出了 FluentTerminal 配合 oh-my-posh 的一套终端方案。

效果展示

FluentTerminal

一款美观的终端工具,个人感觉比 Windows Terminal 更加美观。

下载方式:

  1. 直接去微软自带的应用商店里面去搜索下载。
  2. 前往FluentTerminal 项目地址进行下载

设置鼠标右键打开:

新建个记事本,将下面代码粘贴进去保存。随后将.txt更改为.bat,使用管理员权限运行。
无图标方法:

reg add "HKCUSoftwareClassesDirectoryshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f
reg add "HKCUSoftwareClassesDirectoryBackgroundshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f
reg add "HKCUSoftwareClassesDriveshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f
reg add "HKCUSoftwareClassesLibraryFolderBackgroundshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f

有图标方法:
图标下载地址
将下载的图标和下面的代码放在同一个文件夹。

copy /y FluentTerminal.ico "%LOCALAPPDATA%MicrosoftWindowsApps"
reg add "HKCUSoftwareClassesDirectoryshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f
reg add "HKCUSoftwareClassesDirectoryshellOpen Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%MicrosoftWindowsAppsFluentTerminal.ico" /f
reg add "HKCUSoftwareClassesDirectoryBackgroundshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f
reg add "HKCUSoftwareClassesDirectoryBackgroundshellOpen Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%MicrosoftWindowsAppsFluentTerminal.ico" /f
reg add "HKCUSoftwareClassesDriveshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f
reg add "HKCUSoftwareClassesDriveshellOpen Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%MicrosoftWindowsAppsFluentTerminal.ico" /f
reg add "HKCUSoftwareClassesLibraryFolderBackgroundshellOpen Fluent Terminal herecommand" /d ""%LOCALAPPDATA%MicrosoftWindowsAppsflute.exe" new "%%V"" /f
reg add "HKCUSoftwareClassesLibraryFolderBackgroundshellOpen Fluent Terminal here" /v icon /t REG_SZ /d "%LOCALAPPDATA%MicrosoftWindowsAppsFluentTerminal.ico" /f

删除右键打开代码:

reg delete "HKCUSoftwareClassesDirectoryshellOpen Fluent Terminal here" /f
reg delete "HKCUSoftwareClassesDirectoryBackgroundshellOpen Fluent Terminal here" /f
reg delete "HKCUSoftwareClassesDriveshellOpen Fluent Terminal here" /f
reg delete "HKCUSoftwareClassesLibraryFolderBackgroundshellOpen Fluent Terminal here" /f
del %LOCALAPPDATA%MicrosoftWindowsAppsFluentTerminal.ico
使用oh-my-posh对终端进行美化

oh-my-posh官方文档

使用官方给的方法,在powershell中进行安装。

winget install JanDeDobbeleer.OhMyPosh -s winget

安装后重启终端,使用以下命令初始化。(有时候会出现函数报错,这时需要重启一下电脑)

oh-my-posh init pwsh | Invoke-Expression

初始化之后可能会发现,字体乱码,需要前往 Nerd Font 安装该系列字体。

也可以使用管理员权限运行如下命令来安装字体。

oh-my-posh font install

字体安装后,在相应的终端工具中调整字体。

设置完之后,发现再次打开终端时并不能成功加载 oh-my-posh。我们需要给 powershell 增加初始化脚本。

使用如下命令查看个人配置文件路径。

$profile

在对应显示的地址去创建个人配置文件。

在个人配置文件中写下如下初始化命令。

oh-my-posh init pwsh --config ~/.jandedobbeleer.omp.json | Invoke-Expression

然后使用管理员权限运行以下命令来允许 powershell 每次打开时执行初始化脚本。

set-ExecutionPolicy RemoteSigned

这样再打开终端,就直接可以显示了。

打开终端时,一般会有一些提示显示前面,我们可以再终端工具的设置里启动时参数加上-nologo即可删除启动时的提示。

针对于主题修改,我们可以使用如下命令来预览主题。

Get-PoshThemes

在预览主题的最下面,会有显示主题在我们本机的地址代码示例。

我们将示例地址代码取代我们在 powershell 初始化脚本中的代码,将代码中对应的主题名字替换成我们想换的主题名即可。

比如我们将想用1_shell主题,只需要对照上图中的地址信息修改成如下即可。

oh-my-posh init pwsh --config C:UsersbrokyzAppDataLocalProgramsoh-my-poshthemes/1_shell.omp.json | Invoke-Expression
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1023482.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号