Skip to content

Instantly share code, notes, and snippets.

@z-a-f
Created July 23, 2023 21:16
Show Gist options
  • Save z-a-f/f73c5e663e7fdc815cbbc8b75ecb9e0d to your computer and use it in GitHub Desktop.
Save z-a-f/f73c5e663e7fdc815cbbc8b75ecb9e0d to your computer and use it in GitHub Desktop.
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"console_title_template": "{{ .Shell }} in {{ .Folder }}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#46a2ff",
"template": "\u256d\u2500"
},
{
"type": "os",
"style": "diamond",
"foreground": "#000000",
"background": "#46a2ff",
"background_templates": [
"{{ if .Root }}#ff9c46{{ end }}"
],
"leading_diamond": "\ue0b2",
"template": " {{ if .Root }}\uF0E7 {{ end }}{{ if .WSL }}WSL at {{ end }}{{.Icon}} "
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#e4e4e4",
"background": "#3465a4",
"template": " \uf07c {{ .Path }} ",
"properties": {
"home_icon": "~",
"style": "full"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#000000",
"background": "#4e9a06",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#c4a000{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#f26d50{{ end }}",
"{{ if gt .Ahead 0 }}#89d1dc{{ end }}",
"{{ if gt .Behind 0 }}#4e9a06{{ end }}"
],
"template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
"properties": {
"branch_icon": "\uf126 ",
"fetch_stash_count": true,
"fetch_status": true,
"fetch_upstream_icon": true
}
}
]
},
{
"type": "prompt",
"alignment": "right",
"segments": [
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\ue0b2",
"invert_powerline": true,
"foreground": "#111111",
"background": "#FFDE57",
"template": " \ue235 {{ if .Major }}{{ .Major }}.{{ .Minor }}{{ else }}\uf128.\uf128{{ end }}{{ if .Venv }}(\uf0ac {{ .Venv }}){{ end }} ",
"properties": {
"display_mode": "environment",
"fetch_virtual_env": true,
"home_enabled": true
}
},
{
"type": "exit",
"style": "diamond",
"invert_powerline": true,
"foreground": "#000000",
"background": "#46a2ff",
"background_templates": [
"{{ if gt .Code 0 }}#cc2222{{ end }}"
],
"leading_diamond": "\ue0b2",
"trailing_diamond": "\ue0b0",
"template": " {{ if gt .Code 0 }}{{ .Meaning }}{{ else }}✔{{ end }} ",
"properties": {
"always_enabled": true
}
},
{
"type": "text",
"style": "plain",
"foreground": "#46a2ff",
"template": "\u2500\u256e"
}
]
},
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#46a2ff",
"template": "\u2570\u2500"
}
],
"newline": true
},
{
"type": "rprompt",
"segments": [
{
"type": "executiontime",
"style": "diamond",
"leading_diamond": "\ue0b2",
"trailing_diamond": "\ue0b0",
"invert_powerline": false,
"foreground": "#000000",
"background": "#46a2ff",
"template": " {{ .FormattedMs }} \uf252 "
},
{
"type": "text",
"style": "plain",
"foreground": "#46a2ff",
"template": "\u2500\u256f"
}
]
}
]
}
# Checks if the current shell is elevated
Function Test-Elevated {
$wid = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp = New-Object System.Security.Principal.WindowsPrincipal($wid)
$adm = [System.Security.Principal.WindowsBuiltInRole]::Administrator
$prp.IsInRole($adm)
}
function MessageBox {
param(
[string]$BoxColor = "DarkGray",
[string]$TextColor = "White",
[string]$Icon,
[string]$Message
)
Write-Host " $([char]0xe0b2)" -Foreground $BoxColor -NoNewline
Write-Host " ${Icon} ${Message} " -BackgroundColor $BoxColor -ForegroundColor $TextColor -NoNewline
Write-Host "$([char]0xe0b0)" -Foreground $BoxColor
}
function InfoBox {
param(
[string]$Message
)
MessageBox -Message $Message -BoxColor DarkBlue -TextColor White -Icon "$([char]0xf129)"
}
function WarningBox {
param(
[string]$Message
)
MessageBox -Message $Message -BoxColor DarkYellow -TextColor White -Icon "$([char]0xf071)"
}
function ErrorBox {
param(
[string]$Message
)
MessageBox -Message $Message -BoxColor DarkRed -TextColor White -Icon "$([char]0xf06a)"
}
function DebugBox {
param(
[string]$Message
)
MessageBox -Message $Message -BoxColor DarkGray -TextColor White -Icon "$([char]0xf085)"
}
function MicromambaActivateOrRun {
$envs = micromamba env list --json
$envs = $envs | ConvertFrom-Json
$envs = $envs.envs
$envs = $envs | ForEach-Object { $_.Split(";")[0] }
$envs = $envs | ForEach-Object { $_.Split("\")[-1] }
$env = $args[0]
if (("base" -eq $env) -Or ($envs -contains $env)) {
# Print with UTF-16 characters enabled
$PSDefaultParameterValues['Out-String:Encoding'] = 'unicode'
# Write-Host "$([char]0xf085) $([char]0xe0b2)" -Foreground DarkGray -NoNewline
# Write-Host " Activating $([char]0xf0ac) '$env'... " -BackgroundColor DarkGray -NoNewline
# Write-Host "$([char]0xe0b0)" -Foreground DarkGray
InfoBox -Message "Activating $([char]0xf0ac) '$env'... "
micromamba activate @args
} else {
# Write-Host "===> Attempting to run 'micromamba $args'..." -ForegroundColor Yellow
InfoBox -Message "Running 'micromamba $args'..."
micromamba @args
}
}
# Mamba
Set-Alias -Name "micro" -Value "MicromambaActivateOrRun"
Set-Alias -Name "mamba" -Value "micromamba"
Set-Alias -Name "conda" -Value "micromamba" # VSCode uses `conda` for the integrated terminals`
# Linux-Style aliases
function _LL_Alias{Get-ChildItem -Force -Hidden @args}; Set-Alias -Name "ll" -Value "_LL_Alias"
function _LA_Alias{Get-ChildItem -Force -Hidden @args}; Set-Alias -Name "la" -Value "_LA_Alias"
# Utilities
Set-Alias -Name "isadmin" -Value "Test-Elevated"
Set-Alias -Name "issudo" -Value "Test-Elevated"
# If oh-my-posh is installed, initialize it
# oh-my-posh init pwsh | Invoke-Expression
oh-my-posh init --config "~\.oh-my-posh-theme.omp.json" pwsh | Invoke-Expression
# oh-my-posh init --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" pwsh | Invoke-Expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment