WindowsPowerShell/profile.ps1
Kenneth Benzie (Benie) 0f07186aa1 Remove network workarounds
Since discovering that OpenHardwareMonitor data can be access via
the `Get-WmiObject` powershell command there is no longer any need to
read sensor data from a host port, thus removing the need to unblock
WSL2 VM from accessing the Windows host.
2022-10-01 12:47:23 +01:00

42 lines
1.7 KiB
PowerShell

# Use Cmder's multiline prompt and posh-git.
Import-Module "$env:ChocolateyToolsLocation\Cmder\vendor\profile.ps1"
# Enable Chocolatey completions.
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
# Enable op completions.
Import-Module "$env:LOCALAPPDATA\1Password\cli\opProfile.psm1"
# Set UTF-8 as the character set for pipes and output objects.
# https://gist.github.com/xoner/4671514
$OutputEncoding = New-Object -typename System.Text.UTF8Encoding
[Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
# Enable Vi line editing mode.
Set-PSReadLineOption -BellStyle None -EditMode Vi
# Make C-w backward delete a word.
Set-PSReadLineKeyHandler -Chord Ctrl+w -Function BackwardDeleteWord
# Make C-[ escape insert mode.
# https://github.com/PowerShell/PSReadLine/issues/906#issuecomment-916847040
Set-PSReadLineKeyHandler -Chord 'Ctrl+Oem4' -Function ViCommandMode
# Enable menu style tab completions. https://stackoverflow.com/a/37715242
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Change cursor shape based on what Vi mode the line editor is in.
# Tested and works with PowerShell 5.1
# NOTE: Requires: Install-Module PsReadline -Scope CurrentUser -Force
function OnViModeChange {
if ($args[0] -eq 'Command') {
# Set the cursor to non-blinking block.
Write-Host -NoNewLine "$([char]0x1b)[2 q"
} else {
# Set the cursor to non-blinking line.
Write-Host -NoNewLine "$([char]0x1b)[6 q"
}
}
Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange
# And set the cursor to a non-blinking line on profile load.
Write-Host -NoNewLine "$([char]0x1b)[6 q"
# Remove these aliases to PowerShell builtins which clobber the actaul exes.
Remove-Item alias:curl
Remove-Item alias:wget