美化你的Windows Powershell (1)
美化你的Windows Powershell(1)
Windows的Powershell实际上也是可以像Linux或者Mac的Shell那样进行美化的
准备工作
Windows Terminal
首先你可以先安装一下Windows Terminal,当然这不是必须的,但是它会极大的提高你使用命令行的体验。
可以去GitHub下载或者去Windows商店搜索。
GitHub地址 https://github.com/microsoft/terminal
Powershell
我个人使用的是Powershell,而不是Windows Powershell,注意这两个其实是有区别的。Windows Powershell是Windows系统默认安装的Powershell,它只支持Windows系统。而我这里用的Powershell,也叫Powershell Core,是跨平台的。
对于本文而言,你也可以使用windows powershell。
Powershell Core也可以从GitHub或者Windows商店下载。
GitHub地址 https://github.com/PowerShell/PowerShell
(左边是windows powershell,右边是powershell)
安装 oh-my-posh等Module
oh-my-posh 是一个类似 oh-my-zsh的powershell的配置管理工具(https://ohmyposh.dev/docs)。
先安装 oh-my-posh 和 posh-git
在powershelll里执行下面的命令
Install-Module oh-my-posh -ScopeCurrentUserInstall-Module posh-git -ScopeCurrentUser
然后再安装PSReadLine
Install-Module-NamePSReadLine-AllowPrerelease-ScopeCurrentUser-Force-SkipPublisherCheck设置
在powershell里执行
notepad.exe $PROFILE会打开一个文本文件,这个类似是我们bash的profile。如果你之前没有设置过,那么这个会是一个新建的文件,然后输入下面的内容。其中第三行是设置主题,这个可以根据个人喜好自行选择,可选的主题名字可以在oh-my-posh的网站查询(https://ohmyposh.dev/docs/themes)
Import-Module posh-gitImport-Module oh-my-poshSet-PoshPrompt-Theme robbyrussel
保存,关闭。然后重新打开Powershell。OK,一个配置好的powershell就搞定了。快试试吧。
今天的内容先到这里,下次我们聊聊字体,配色,文件类型,自动补全等。
欢迎关注我的公众号“卖逗搞IT”,原创技术文章第一时间推送。