Windows7下powershell配置

之前升级换下的电脑我撤下了win10,恢复了之前备份的win7,主要是平时还有些东西需要在win7下面跑,但是也有不太爽的地方,比如Windows Terminal没法用了,PowerShell版本也偏低,默认只能升级到5.x版本,但是我还是尝试了一堆版本,经过一段时间使用,最后找到了合适的版本7.0.3,配合ConEmuoh-my-posh也能达到Windows Terminal效果, 展示如下

关键点是PowerShellprofile文件配置,在ConEmu设置->启动->任务

PowerShell 7的设置如下

*pwsh -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression 'Import-Module ''%ConEmuDir%\..\profile7.ps1'''"

ps1脚本你也可以进行一些所需的配置,比如使用oh-my-posh,输出启动画面及代理函数等,下面是我自己的配置,

Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

oh-my-posh --init --shell pwsh --config $env:POSH_THEMES_PATH/wholespace.omp.json | Invoke-Expression

Import-Module -Name Terminal-Icons
Import-Module posh-git

# welcome
# clear
$hello="
 _______  _______  _______  _______  _______  _______ 
(  ____ \(  ___  )(  ____ \(  ___  )/ ___   )(  ___  )
| (    \/| (   ) || (    \/| (   ) |\/   )  || (   ) |
| |      | |   | || |      | |   | |    /   )| |   | |
| |      | |   | || |      | |   | |   /   / | |   | |
| |      | |   | || |      | |   | |  /   /  | | /\| |
| (____/\| (___) || (____/\| (___) | /   (_/\| (_\ \ |
(_______/(_______)(_______/(_______)(_______/(____\/_)

"
$hello
# neofetch
"Welcome, CocoZQ!"

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

 桂ICP备15001694号-3