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 79 additions and 78 deletions

View File

@ -6,14 +6,12 @@ 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
@ -22,6 +20,18 @@ 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
@ -31,6 +41,7 @@ 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 (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"
}
elseif (Test-Path (Join-Path $PWD $venv)) {
& "$venv/Scripts/activate.ps1"
}
else {
Write-Error "Environment '${venv}' does not exists."
}
@ -51,6 +51,10 @@ function venv {
deactivate
}
"list-python" {
py -0 | Select-Object -Skip 1
}
default {
Write-Error "Unknown venv command ${args[0]}."
}

View File

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