From 132696d34e977eb6077e09b64060a723e224dc39 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sun, 6 Feb 2022 17:13:56 +0000 Subject: [PATCH] Add profile.ps1 file --- profile.ps1 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 profile.ps1 diff --git a/profile.ps1 b/profile.ps1 new file mode 100644 index 0000000..74e137a --- /dev/null +++ b/profile.ps1 @@ -0,0 +1,44 @@ +# 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" + +# 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 +# TODO: Doesn't work with PSReadLine 2.1 +# Hoping this gets fixed at some point and will just start working. +Set-PSReadLineKeyHandler -Chord Ctrl+[ -Function ViCommandMode +# Workaround is to use C-i instead, which is fitting with Vi I guess. +# TODO: Remove C-i if C-[ gets fixed. +Set-PSReadLineKeyHandler -Chord Ctrl+i -Function ViCommandMode + +# # Change cursor shape based on what Vi mode the line editor is in. +# # Testing and works with PowerShell 5.1 +# # NOTE: Requires: Install-Module PsReadline -Scope CurrentUser -Force +# # FIXME: Doesn't work with PSReadLine 2.0 +# 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 + +# Allow the VM running WSL2 to access Windows host, setting is not persistent over reboots +New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow > $null