Skip to content

Instantly share code, notes, and snippets.

@lkurzyniec
Last active February 15, 2024 15:28
Show Gist options
  • Save lkurzyniec/7a4078689e97f3f8ca81e7d4c67f042d to your computer and use it in GitHub Desktop.
Save lkurzyniec/7a4078689e97f3f8ca81e7d4c67f042d to your computer and use it in GitHub Desktop.
PowerShell profile
# Import-Module posh-git
oh-my-posh init pwsh --config ~/lk.omp.json | Invoke-Expression
Import-Module -Name Terminal-Icons
# Enable-PoshTooltips
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
Import-Module DockerCompletion
Set-PSReadLineOption -PredictionSource History # F2 to switch
# Set-PSReadLineOption -PredictionViewStyle ListView
}
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
# Chocolatey profile
# dotnet suggest shell start
# more info: https://github.com/dotnet/command-line-api/blob/main/docs/dotnet-suggest.md
if (Get-Command "dotnet-suggest" -errorAction SilentlyContinue)
{
$availableToComplete = (dotnet-suggest list) | Out-String
$availableToCompleteArray = $availableToComplete.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries)
Register-ArgumentCompleter -Native -CommandName $availableToCompleteArray -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$fullpath = (Get-Command $commandAst.CommandElements[0]).Source
$arguments = $commandAst.Extent.ToString().Replace('"', '\"')
dotnet-suggest get -e $fullpath --position $cursorPosition -- "$arguments" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}
else
{
"Unable to provide System.CommandLine tab completion support unless the [dotnet-suggest] tool is first installed."
"See the following for tool installation: https://www.nuget.org/packages/dotnet-suggest"
}
$env:DOTNET_SUGGEST_SCRIPT_VERSION = "1.0.2"
# dotnet suggest script end
for($i = 2; $i -le 5; $i++){
$d = "".PadLeft($i,".")
$u = "".PadLeft($i-1,".").Replace(".", "../")
Invoke-Expression "function $d { push-location $u }"
}
Set-Alias -Name tf -Value "C:\ProgramData\chocolatey\lib\terraform\tools\terraform.exe" -Scope Global
Write-Host "PowerShell Ready" -ForegroundColor Green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment