Compare commits

...

6 Commits

Author SHA1 Message Date
Mikaël Capelle
6a9c4bb7e2 Fix order of if/elseif in posh-venv. 2023-07-24 20:03:37 +02:00
Mikael CAPELLE
cb4291d6d8 Remove node segment. 2023-07-17 15:02:08 +02:00
Mikael CAPELLE
27a2b99254 Switch username fg to #ddd. 2023-07-17 14:57:46 +02:00
Mikael CAPELLE
12913b0cc5 Add hostname to theme for SSH. 2023-07-17 10:37:43 +02:00
Mikael CAPELLE
fc6a31e98f Change icon for home. 2023-07-13 10:21:19 +02:00
Mikaël Capelle
85e8b4247b Update. 2023-07-12 20:05:44 +02:00
3 changed files with 103 additions and 86 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

@ -36,12 +36,12 @@ function venv {
if (Test-Path "$env:WORKON_HOME/$venv/Scripts/activate.ps1") { if (Test-Path "$env:WORKON_HOME/$venv/Scripts/activate.ps1") {
& "$env:WORKON_HOME/$venv/Scripts/activate.ps1" & "$env:WORKON_HOME/$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")) { elseif ((!$venv -Or !$venv.Trim()) -And (Test-Path "venv/Scripts/activate.ps1")) {
& "venv/Scripts/activate.ps1" & "venv/Scripts/activate.ps1"
} }
elseif (Test-Path (Join-Path $PWD $venv)) {
& "$venv/Scripts/activate.ps1"
}
else { else {
Write-Error "Environment '${venv}' does not exists." Write-Error "Environment '${venv}' does not exists."
} }
@ -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,149 @@
{ {
"$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"
}, },
{ {
"foreground": "#ffffff", "type": "session",
"style": "plain",
"foreground": "#ddd",
"template": " {{ if .SSHSession }}\udb80\udf18 {{ end }}{{ .UserName }}{{ if .SSHSession }}@{{ .HostName }}{{ end }}",
"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": [
{ {
"foreground": "#fff000", "type": "go",
"properties": {
"prefix": " \ufcb5 ",
"var_name": "__SHELL_INFORMATION_POSH_258__"
},
"style": "powerline", "style": "powerline",
"type": "envvar"
},
{
"foreground": "#b600ff",
"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": "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": "\uf015 ",
"style": "letter" "style": "letter"
}, }
"style": "powerline",
"template": " {{ .Path }} ",
"type": "path"
}, },
{ {
"foreground": "#193549", "type": "git",
"powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": " {{ .Status }} ", "powerline_symbol": "",
"type": "poshgit" "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": "prompt"
}, },
{ {
"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
} }