pwsh-conf/Microsoft.PowerShell_profil...

48 lines
1.7 KiB
PowerShell

# Import module:
$profile_folder = (Split-Path -Parent $PROFILE)
Import-Module posh-git
$env:POSH_GIT_ENABLED = $true
$env:VIRTUAL_ENV_DISABLE_PROMPT = "True"
oh-my-posh init pwsh --config (Join-Path $profile_folder theme.omp.json) | Invoke-Expression
Import-Module posh-ssh
Import-Module posh-venv
Import-Module DockerCompletion
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadlineOption -BellStyle None
if (Get-Command winget -ErrorAction SilentlyContinue) {
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}
# kube / helm
if (Get-Command kubectl -ErrorAction SilentlyContinue) {
kubectl completion powershell | Out-String | Invoke-Expression
}
if (Get-Command helm -ErrorAction SilentlyContinue) {
helm completion powershell | Out-String | Invoke-Expression
}
# Gitlab CLI
if (Get-Command glab -ErrorAction SilentlyContinue) {
glab completion -s powershell | Out-String | Invoke-Expression
}