Files
shellscripts/powershellScripts/setup_psreadline.ps1
Your Name b00f025742 update
2024-11-12 00:07:46 +08:00

23 lines
825 B
PowerShell

# Install the PSReadLine module
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
# Check if the profile exists and create it if not
if (!(Test-Path -Path $PROFILE)) {
New-Item -Type File -Path $PROFILE -Force
}
# Add PSReadLine configuration to the PowerShell profile
Add-Content -Path $PROFILE -Value '
Import-Module PSReadLine
Set-PSReadLineOption -EditMode Emacs
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -ShowToolTips
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
'
# Output the content to check
Write-Output "PSReadLine module installation and profile configuration script created."