This commit is contained in:
Mikaël Capelle 2023-07-12 20:04:10 +02:00
parent b3b446599a
commit 85e8b4247b
3 changed files with 110 additions and 77 deletions

View File

@ -6,11 +6,8 @@ Import-Module posh-git
$env:POSH_GIT_ENABLED = $true $env:POSH_GIT_ENABLED = $true
$env:VIRTUAL_ENV_DISABLE_PROMPT = "True" $env:VIRTUAL_ENV_DISABLE_PROMPT = "True"
oh-my-posh init pwsh --config (Join-Path $profile_folder theme.omp.json) | Invoke-Expression
function docker { oh-my-posh init pwsh --config (Join-Path $profile_folder theme.omp.json) | Invoke-Expression
wsl -- docker $args
}
Import-Module posh-ssh Import-Module posh-ssh
Import-Module posh-venv Import-Module posh-venv
@ -23,6 +20,18 @@ Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadlineOption -BellStyle None 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 # kube / helm
if (Get-Command kubectl -ErrorAction SilentlyContinue) { if (Get-Command kubectl -ErrorAction SilentlyContinue) {
kubectl completion powershell | Out-String | Invoke-Expression kubectl completion powershell | Out-String | Invoke-Expression
@ -31,3 +40,8 @@ if (Get-Command kubectl -ErrorAction SilentlyContinue) {
if (Get-Command helm -ErrorAction SilentlyContinue) { if (Get-Command helm -ErrorAction SilentlyContinue) {
helm completion powershell | Out-String | Invoke-Expression helm completion powershell | Out-String | Invoke-Expression
} }
# Gitlab CLI
if (Get-Command glab -ErrorAction SilentlyContinue) {
glab completion -s powershell | Out-String | Invoke-Expression
}

View File

@ -51,6 +51,10 @@ function venv {
deactivate deactivate
} }
"list-python" {
py -0 | Select-Object -Skip 1
}
default { default {
Write-Error "Unknown venv command ${args[0]}." Write-Error "Unknown venv command ${args[0]}."
} }

View File

@ -1,150 +1,165 @@
{ {
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"blocks": [ "blocks": [
{ {
"type": "prompt",
"alignment": "left", "alignment": "left",
"segments": [ "segments": [
{ {
"foreground": "#ffee58", "type": "root",
"style": "plain", "style": "plain",
"template": " \uf0e7 ", "foreground": "#ffee58",
"type": "root" "template": " \uf0e7 "
}, },
{ {
"type": "exit",
"style": "powerline",
"foreground": "#06884b", "foreground": "#06884b",
"foreground_templates": [ "foreground_templates": ["{{ if gt .Code 0 }}#e61010{{ end }}"],
"{{ if gt .Code 0 }}#e61010{{ end }}" "template": " {{ if gt .Code 0 }}✗{{ else }}✔{{ end }} ",
],
"properties": { "properties": {
"always_enabled": true "always_enabled": true
}, }
"style": "powerline",
"template": " {{ if gt .Code 0 }}\u2717{{ else }}\u2714{{ end }} ",
"type": "exit"
}, },
{ {
"type": "session",
"style": "plain",
"foreground": "#ffffff", "foreground": "#ffffff",
"template": " {{ if .SSHSession }}\udb80\udf18 {{ end }}{{ .UserName }}",
"properties": { "properties": {
"display_host": false "display_host": false
},
"style": "plain",
"template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }}",
"type": "session"
} }
], }
"type": "prompt" ]
}, },
{ {
"type": "prompt",
"alignment": "left", "alignment": "left",
"segments": [ "segments": [
{ {
"type": "envvar",
"style": "powerline",
"foreground": "#fff000", "foreground": "#fff000",
"properties": { "properties": {
"prefix": " \ufcb5 ", "prefix": " \udb81\udfb7 ",
"var_name": "__SHELL_INFORMATION_POSH_258__" "var_name": "__SHELL_INFORMATION_POSH_258__"
}, }
"style": "powerline",
"type": "envvar"
}, },
{ {
"foreground": "#b600ff", "type": "go",
"style": "powerline", "style": "powerline",
"template": " \ufcd1 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
"type": "go"
},
{
"foreground": "#b600ff",
"style": "powerline",
"template": " \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} ",
"type": "node"
},
{
"background": "#b600ff",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#983ebb",
"template": " \udb81\udfd3 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
},
{
"type": "node",
"style": "powerline",
"foreground": "#ffffff",
"background": "#983ebb",
"template": " \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} "
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"foreground": "#ffffff",
"background": "#983ebb",
"template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ",
"properties": { "properties": {
"display_mode": "context", "display_mode": "context",
"home_enabled": true "home_enabled": true
},
"style": "powerline",
"template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ",
"type": "python"
} }
], }
"type": "prompt" ]
}, },
{ {
"type": "prompt",
"alignment": "left", "alignment": "left",
"segments": [ "segments": [
{ {
"foreground": "#8e24aa", "type": "os",
"style": "plain", "style": "plain",
"template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}} ", "foreground": "#8e24aa",
"type": "os" "template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}} "
}, },
{ {
"background": "#0037da", "type": "path",
"foreground": "#ffffff", "style": "powerline",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"foreground": "#ffffff",
"background": "#3156c4",
"template": " {{ .Path }} ",
"properties": { "properties": {
"folder_separator_icon": " \ue0b1 ", "folder_separator_icon": " \ue0b1 ",
"home_icon": "\uf7db", "home_icon": "\uf4e2",
"style": "letter" "style": "letter"
},
"style": "powerline",
"template": " {{ .Path }} ",
"type": "path"
},
{
"foreground": "#193549",
"powerline_symbol": "\ue0b0",
"style": "powerline",
"template": " {{ .Status }} ",
"type": "poshgit"
} }
],
"type": "prompt"
}, },
{ {
"type": "git",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#193549",
"background": "#ffeb3b",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FFEB3B{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#FFCC80{{ end }}",
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
"{{ if gt .Behind 0 }}#B388FB{{ end }}"
],
"template": "{{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }}  {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}  {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }}  {{ .StashCount }}{{ end }}",
"properties": {
"fetch_status": true,
"fetch_stash_count": true,
"fetch_upstream_icon": true,
"untracked_modes": {
"/Users/user/Projects/oh-my-posh/": "no"
}
}
}
]
},
{
"type": "rprompt",
"alignment": "right", "alignment": "right",
"segments": [ "segments": [
{ {
"foreground": "#8454bb", "type": "executiontime",
"style": "plain",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"foreground": "#8454bb",
"template": " <#fefefe>\udb81\udead</> {{ .FormattedMs }} ",
"properties": { "properties": {
"style": "austin", "style": "austin",
"threshold": 500 "threshold": 500
}, }
"style": "plain",
"template": " <#fefefe>\ufbab</> {{ .FormattedMs }} ",
"type": "executiontime"
}, },
{ {
"type": "time",
"style": "plain",
"foreground": "#007ACC", "foreground": "#007ACC",
"template": " {{ .CurrentDate | date .Format }} ",
"properties": { "properties": {
"time_format": "[15:04:05]" "time_format": "[15:04:05]"
},
"style": "plain",
"template": " {{ .CurrentDate | date .Format }} ",
"type": "time"
} }
], }
"type": "rprompt" ]
}, },
{ {
"type": "prompt",
"alignment": "left", "alignment": "left",
"newline": true,
"segments": [ "segments": [
{ {
"foreground": "#0037da", "type": "text",
"style": "powerline", "style": "powerline",
"template": " \u276f ", "foreground": "#3156c4",
"type": "text" "template": " \u276f "
} }
], ],
"type": "prompt" "newline": true
} }
], ]
"final_space": true,
"version": 2
} }