杂笔:windows powershell主题配置

2,238 阅读1分钟

自从 Windows Terminal 发布后,在终端里敲命令也不是那么便扭。But 作为一个前端,追求美是我们的天性,用过 mac 上的 oh-my-zsh 后,发觉终端里的配色也是索然无味,幸运的是伟大的开源社区亦贡献了套 powershell 主题配置!

安装

需要的环境:

  • windows powershell
  • Git
  • Cascadia Code(微软开源的代码字体)

字体文件去官方仓库 Releases 下载,选择 Cascadia Code PL,打开文件点击安装就行了。

用 powershell 装 2 个包:posh-git(git 状态提示与补全)、oh-my-posh(主题)

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

使用

显然装包后没什么变化,那是因为需要启用。类似 zsh 的 .zshrc 配置文件,powershell 也有。通过 notepad $PROFILE 创建编辑它,这个脚本在 powershell 每次运行前都会执行一遍。

看内容大致就知道在干嘛了:

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

相比于上面那个花里胡哨的主题,我更喜欢 Robbyrussell。附上一张效果图:

Robbyrussel

参考链接