Skip to content

Instantly share code, notes, and snippets.

@benitogf
Last active June 22, 2021 06:59
Show Gist options
  • Save benitogf/bfd3ff248f421126dcae19b8a191f199 to your computer and use it in GitHub Desktop.
Save benitogf/bfd3ff248f421126dcae19b8a191f199 to your computer and use it in GitHub Desktop.
PowerShell profile
# https://superuser.com/questions/1199882/powershell-auto-complete-settings
# https://stackoverflow.com/questions/8264655/how-to-make-powershell-tab-completion-work-like-bash
# https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/SamplePSReadLineProfile.ps1
# https://gist.github.com/jchandra74/5b0c94385175c7a8d1cb39bc5157365e
# https://www.hanselman.com/blog/HowToMakeAPrettyPromptInWindowsTerminalWithPowerlineNerdFontsCascadiaCodeWSLAndOhmyposh.aspx
# to install dependencies run from pwshell:
# Install-Module posh-git -Scope CurrentUser
# Install-Module oh-my-posh -Scope CurrentUser
# Install-Module -Name 'Get-ChildItemColor' -Scope CurrentUser
# Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber
# then copy this file in the profile:
# notepad.exe $PROFILE
# then install a font like: https://github.com/microsoft/cascadia-code/releases?WT.mc_id=-blog-scottha and enable it in the terminal settings
Import-Module posh-git
Import-Module oh-my-posh
Import-Module PSReadLine
Set-PSReadLineKeyHandler -Key Tab -Function Complete
# Ensure that Get-ChildItemColor is loaded
Import-Module Get-ChildItemColor
# Set l and ls alias to use the new Get-ChildItemColor cmdlets
Set-Alias l Get-ChildItemColor -Option AllScope
Set-Alias ll Get-ChildItemColor -Option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -Option AllScope
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
# Helper function to show Unicode character
function U
{
param
(
[int] $Code
)
if ((0 -le $Code) -and ($Code -le 0xFFFF))
{
return [char] $Code
}
if ((0x10000 -le $Code) -and ($Code -le 0x10FFFF))
{
return [char]::ConvertFromUtf32($Code)
}
throw "Invalid character code $Code"
}
# https://github.com/microsoft/terminal/issues/9237#issuecomment-798913706
Set-PoshPrompt Agnoster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment