在 Windows 终端中设置 Powerline

这种效果

1、安装 Powerline 字体

字体下载地址

安装其中的 Cascadia Code PL 或 Cascadia Mono PL

2、PowerShell 必备条件

在此之前自行安装 git

使用 PowerShell,安装 Posh-Git 和 Oh-My-Posh

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

如果使用的是 PowerShell Core,请安装 PSReadline

Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

3、自定义 PowerShell 提示符(这里我已经安装了 Visual Studio Code 到 path)

code $PROFILE

在文件尾部添加如下

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt Paradox  # Set-Theme 指令已经被 Set-PoshPrompt 取代

现在,每个新实例启动时都会导入 Posh-Git 和 Oh-My-Posh,然后从 Oh-My-Posh 设置 Paradox 主题

PS. 有可能因为策略原因打开失败,可以尝试

get-ExecutionPolicy   # 查看系统执行策略状态
 
set-executionpolicy remotesigned # 修改执行策略状态,改为一直允许

记得右键 Powerline 修改字体

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容