Loading

使用oh-my-posh美化powershell

2020/03/22, powershell, oh-my-posh

摘要:使用oh-my-posh美化powershell
美化教程参考少数派文章5 个 PowerShell 主题,让你的 Windows 终端更好看

美化效果图,此图是在FluentTerminal下的效果:

准备工作

电脑中需要安装好git、支持Powerline的字体
git可以去官网下载,如果觉得速度慢,可以考虑在腾讯软件中搜索下载(速度很快,而且使用普通下载的方式安装包没有夹带私货)

powerline字体需要去github下载,powerline/fonts地址
而我自己更喜欢使用 更纱黑体github地址

修改字体

打开powershell,对着标题栏右击,选择属性

安装主题

执行以下命令安装posh-git和oh-my-posh两个模块,遇到提示选y确认即可,如果下载速度慢,考虑使用小火箭加速

Install-Module posh-git -Scope CurrentUser 
Install-Module oh-my-posh -Scope CurrentUser

新增配置文件

# 如果之前没有配置文件,就新建一个 PowerShell 配置文件
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }

用记事本打开配置文件

notepad $PROFILE

在其中写入以下内容

Import-Module posh-git 
Import-Module oh-my-posh 
Set-Theme Paradox

至此,再重新打开powershell时,会自动加载Paradox主题,一共是
Agnoster、Avit、Darkblood、Fish、Honukai、
Paradox、PowerLine、robbyrussell、Sorin、tehrob这些主题,自己挑选

使用FluentTerminal

去github中下载安装FluentTerminal,使用ps运行Install.ps1安装即可

问题解决

1.如果提示git command could not be found要么是git没装,要么是装好没重启下,因为git命令加入到环境变量后,重启才生效

2.提示"无法加载文件...因为在此系统上禁止运行脚本",以管理员方式运行powershell,输入set-executionpolicy remotesigned命令,回车选y即可

3.在Visual Studio Code的终端中,主题存在行高的问题:

在设置中修改终端的渲染方式即可,我选择为dom就正常了,如有问题,可以切换其他渲染方式试试

posted @ 2020-03-22 20:07  kasnti  阅读(6045)  评论(0编辑  收藏  举报