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

关键点是PowerShell的profile文件配置,在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!"