Compare commits

..

2 Commits

Author SHA1 Message Date
Mikael CAPELLE
bbd7660c0a Add glab auto-completion. 2023-07-03 18:09:27 +02:00
Mikael CAPELLE
c35e62cc96 Fix theme for Git. 2023-07-03 16:44:21 +02:00
3 changed files with 83 additions and 84 deletions

View File

@ -6,12 +6,14 @@ 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
Import-Module Set-PsEnv
Enable-Dotenv
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
@ -20,18 +22,6 @@ 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
@ -41,7 +31,6 @@ 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
}

View File

@ -36,12 +36,12 @@ function venv {
if (Test-Path "$env:WORKON_HOME/$venv/Scripts/activate.ps1") {
& "$env:WORKON_HOME/$venv/Scripts/activate.ps1"
}
elseif ((!$venv -Or !$venv.Trim()) -And (Test-Path "venv/Scripts/activate.ps1")) {
& "venv/Scripts/activate.ps1"
}
elseif (Test-Path (Join-Path $PWD $venv)) {
& "$venv/Scripts/activate.ps1"
}
elseif ((!$venv -Or !$venv.Trim()) -And (Test-Path "venv/Scripts/activate.ps1")) {
& "venv/Scripts/activate.ps1"
}
else {
Write-Error "Environment '${venv}' does not exists."
}
@ -51,10 +51,6 @@ function venv {
deactivate
}
"list-python" {
py -0 | Select-Object -Skip 1
}
default {
Write-Error "Unknown venv command ${args[0]}."
}

View File

@ -1,86 +1,97 @@
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "root",
"style": "plain",
"foreground": "#ffee58",
"template": " \uf0e7 "
"style": "plain",
"template": " \uf0e7 ",
"type": "root"
},
{
"type": "exit",
"style": "powerline",
"foreground": "#06884b",
"foreground_templates": ["{{ if gt .Code 0 }}#e61010{{ end }}"],
"template": " {{ if gt .Code 0 }}✗{{ else }}✔{{ end }} ",
"properties": {
"always_enabled": true
}
},
"style": "powerline",
"template": " {{ if gt .Code 0 }}\u2717{{ else }}\u2714{{ end }} ",
"type": "exit"
},
{
"type": "session",
"style": "plain",
"foreground": "#ddd",
"template": " {{ if .SSHSession }}\udb80\udf18 {{ end }}{{ .UserName }}{{ if .SSHSession }}@{{ .HostName }}{{ end }}",
"foreground": "#ffffff",
"properties": {
"display_host": false
},
"style": "plain",
"template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }}",
"type": "session"
}
}
]
],
"type": "prompt"
},
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "go",
"foreground": "#fff000",
"properties": {
"prefix": " \ufcb5 ",
"var_name": "__SHELL_INFORMATION_POSH_258__"
},
"style": "powerline",
"foreground": "#ffffff",
"background": "#983ebb",
"template": " \udb81\udfd3 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
"type": "envvar"
},
{
"type": "python",
"foreground": "#b600ff",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"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",
"background": "#983ebb",
"template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ",
"powerline_symbol": "\ue0b0",
"properties": {
"display_mode": "context",
"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",
"segments": [
{
"type": "os",
"style": "plain",
"foreground": "#8e24aa",
"template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}} "
"style": "plain",
"template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}} ",
"type": "os"
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "#0037da",
"foreground": "#ffffff",
"background": "#3156c4",
"template": " {{ .Path }} ",
"powerline_symbol": "\ue0b0",
"properties": {
"folder_separator_icon": " \ue0b1 ",
"home_icon": "\uf015 ",
"home_icon": "\uf7db",
"style": "letter"
}
},
"style": "powerline",
"template": " {{ .Path }} ",
"type": "path"
},
{
"type": "git",
@ -104,46 +115,49 @@
}
}
}
]
],
"type": "prompt"
},
{
"type": "rprompt",
"alignment": "right",
"segments": [
{
"type": "executiontime",
"style": "plain",
"powerline_symbol": "\ue0b0",
"foreground": "#8454bb",
"template": " <#fefefe>\udb81\udead</> {{ .FormattedMs }} ",
"powerline_symbol": "\ue0b0",
"properties": {
"style": "austin",
"threshold": 500
}
},
"style": "plain",
"template": " <#fefefe>\ufbab</> {{ .FormattedMs }} ",
"type": "executiontime"
},
{
"type": "time",
"style": "plain",
"foreground": "#007ACC",
"template": " {{ .CurrentDate | date .Format }} ",
"properties": {
"time_format": "[15:04:05]"
}
}
]
},
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "text",
"style": "powerline",
"foreground": "#3156c4",
"template": " \u276f "
"style": "plain",
"template": " {{ .CurrentDate | date .Format }} ",
"type": "time"
}
],
"newline": true
"type": "rprompt"
},
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#0037da",
"style": "powerline",
"template": " \u276f ",
"type": "text"
}
]
],
"type": "prompt"
}
],
"final_space": true,
"version": 2
}