Skip to content

Instantly share code, notes, and snippets.

@JoshCode
Last active May 8, 2023 17:32
Show Gist options
  • Save JoshCode/e7d02191a53caf05f655ff095d8621a2 to your computer and use it in GitHub Desktop.
Save JoshCode/e7d02191a53caf05f655ff095d8621a2 to your computer and use it in GitHub Desktop.
Windows PowerShell 7 customisation
# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
final_space: true
version: 2
blocks:
- type: prompt
alignment: left
segments:
- type: session
style: diamond
background: "#303030"
foreground: "#eeeeee"
leading_diamond: "\ue0b6"
trailing_diamond: "\ue0b0"
properties:
display_host: false
display_user: true
template: " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }} "
- type: "path"
style: "powerline"
foreground: "#ffffff"
background: "#601b3b"
powerline_symbol: "\ue0b0"
properties:
style: "agnoster_short"
template: " \ue5ff {{ .Path }} "
- type: "git"
style: "powerline"
powerline_symbol: "\uE0B0"
foreground: "#193549"
background: "#e3e57b"
# foreground: "#0d1b25"
# background: "#F05032"
background_templates:
- "{{ if or (.Working.Changed) (.Staging.Changed) }}#f4f75b{{ end }}"
- "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#FFCC80{{ end }}"
- "{{ if gt .Ahead 0 }}#B388FF{{ end }}"
- "{{ if gt .Behind 0 }}#B388FB{{ end }}"
properties:
fetch_status: true
fetch_stash_count: true
fetch_upstream_icon: true
fetch_worktree_count: false
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 }} \uF692 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }} "
- type: "shell"
style: "powerline"
foreground: "#ffffff"
background: "#0077c2"
powerline_symbol: "\uE0B0"
templates:
# If name matches non-ASCII regex, it's a shell symbol from mapped_shell_names
# In that case, don't append terminal icon, else do append
- "{{ if (regexMatch \"[^\\x00-\\x7F]\" .Name) }}{{ .Name }}{{ end }}"
- "\uFCB5 {{ .Name }}"
templates_logic: "first_match"
properties:
mapped_shell_names:
# pwsh: "\uEBC7"
bash: "\uEBCA"
fish: "\uF739"
template: " {{ .Templates }} "
- type: "root"
style: "powerline"
foreground: "#193549"
background: "#ffff66"
powerline_symbol: "\ue0b0"
template: " \uf0e7 "
- type: "prompt"
alignment: "right"
segments:
- type: "text"
style: "powerline"
foreground: "#fafafa"
background: "#303030"
powerline_symbol: "\uE0B2"
invert_powerline: true
- type: "node"
style: "powerline"
foreground: "#6CA35E"
background: "#303030"
powerline_symbol: "\uE0B2"
invert_powerline: true
template: " \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} "
- type: "go"
style: "diamond"
foreground: "#111111"
background: "#8ED1F7"
powerline_symbol: "\ue0b0"
invert_powerline: true
properties:
fetch_version: true
template: " \ue626 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
- type: "java"
style: "powerline"
foreground: "#ffffff"
background: "#4063D8"
powerline_symbol: "\uE0B2"
invert_powerline: true
template: " \uE738 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
- type: "kotlin"
style: "powerline"
foreground: "#ffffff"
background: "#906cff"
powerline_symbol: "\uE0B2"
invert_powerline: true
template: " \ufa05 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
- type: "julia"
style: "diamond"
foreground: "#111111"
background: "#4063D8"
powerline_symbol: "\uE0B2"
invert_powerline: true
properties:
fetch_version: true
template: " \ue624 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
- type: "python"
style: "powerline"
foreground: "#96E072"
background: "#303030"
powerline_symbol: "\uE0B2"
invert_powerline: true
template: " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} "
- type: "ruby"
style: "powerline"
foreground: "#ffffff"
background: "#AE1401"
powerline_symbol: "\uE0B2"
invert_powerline: true
properties:
display_mode: "files"
fetch_version: true
template: " \ue791 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
- type: "rust"
style: "powerline"
foreground: "#193549"
background: "#99908a"
powerline_symbol: "\uE0B2"
invert_powerline: true
template: " \uE7a8 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
- type: "azfunc"
style: "powerline"
powerline_symbol: "\uE0B2"
background: "#FEAC19"
foreground: "#ffffff"
properties:
display_mode: "files"
fetch_version: false
template: " \uf0e7 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
- type: "aws"
style: "powerline"
powerline_symbol: "\uE0B2"
foreground: "#ffffff"
background_templates:
- '{{if contains "default" .Profile}}#FFA400{{end}}'
- '{{if contains "jan" .Profile}}#f1184c{{end}}'
properties:
display_default: false
template: " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} "
- type: "dotnet"
style: "powerline"
powerline_symbol: "\uE0B2"
foreground: "#3891A6"
background: "#303030"
invert_powerline: true
properties:
fetch_version: true
template: " \uE77F {{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }}<#7a7a7a> \ue0b3</>"
- type: "battery"
style: "powerline"
powerline_symbol: "\uE0B2"
foreground: "#ffffff"
background: "#f36943"
background_templates:
- '{{ if eq "Full" .State.String }}#4caf50{{ end }}'
- '{{ if eq "Charging" .State.String }}#40c4ff{{ end }}'
- '{{ if eq "Discharging" .State.String }}#ff5722{{ end }}'
invert_powerline: true
properties:
charged_icon: "\ue22f "
charging_icon: "\ue234 "
discharging_icon: "\ue231 "
template: " {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}\uf295 "
- type: "time"
style: "diamond"
invert_powerline: true
foreground: "#fafafa"
background: "#303030"
leading_diamond: "\uE0B2"
trailing_diamond: "\uE0B4"
properties:
time_format: "15:04:05"
template: " {{ .CurrentDate | date .Format }}<#007ACC> \uf64f </>"
- type: "prompt"
alignment: "left"
newline: true
segments:
- type: "text"
style: "plain"
foreground: "#7a7a7a"
template: " ~#@\u276f"
- type: "rprompt"
alignment: "right"
segments:
- type: "text"
style: "plain"
foreground: "#7a7a7a"
template: " \u276e "
- type: "executiontime"
style: "plain"
foreground: "#FFCE5C"
properties:
style: "roundrock"
threshold: 500
template: " {{ .FormattedMs }}<#fafafa> \uf252 </>"
- type: "exit"
style: "plain"
foreground: "#9FD356"
foreground_templates:
- "{{ if gt .Code 0 }}#E84855{{ end }}"
properties:
always_enabled: true
template: " \uf705 {{ if gt .Code 0 }}\uf00d {{ .Code }}{{ else }}\uf42e{{ end }} "
secondary_prompt:
background: "transparent"
foreground: "#7a7a7a"
template: " ~~\u276f "
# valid_line:
# background: "transparent"
# foreground: "#ffffff"
# template: "<#7a7a7a,transparent>@</><#7a7a7a,transparent>\u276F</> "
# error_line:
# background: "transparent"
# foreground: "#ffffff"
# template: "<#eb6f92,transparent>\ue009</><#7a7a7a,transparent>\u276F</> "
transient_prompt:
background: "transparent"
foreground: "#7a7a7a"
template: " ~#@\u276f "
console_title_template: "{{if .Root}}root :: {{end}}{{.Shell}} :: {{.Folder}}"
Import-Module ZLocation
Import-Module PSFzf
# Check if `which` alias exists
if (!(get-alias -name which*)) {
# If not, add it
New-Alias which Get-Command
}
# 2022-05-30 Joshua
# Don't remember why this was here
# if (!(get-alias -name pwdw*)) {
# # Check if `pwdw` alias exists
# New-Alias pwdw Get-Location # If not, add it
# }
# PSReadLine
if ($host.Name -eq 'ConsoleHost') {
Import-Module PSReadLine
Set-PSReadLineOption -EditMode Windows
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadlineKeyHandler -Chord 'Ctrl+t' -ScriptBlock { Invoke-Fzf }
# Set-PSReadlineKeyHandler -Chord 'Ctrl+d' -ScriptBlock {Invoke-FuzzyEdit}
}
# Import console promts and theme
oh-my-posh.exe --init --shell pwsh --config ~/.omp-theme-joshcode.omp.yaml | Invoke-Expression
Enable-PoshTransientPrompt
# Import terminal icons
Import-Module -Name Terminal-Icons
# Bind common Linux commands to aliases which run in WSL
Import-WslCommand "apt", "awk", "emacs", "grep", "head", "less", "ls", "man", "sed", "seq", "sudo", "tail", "vim", "nano", "exa", "rg"
$WslDefaultParameterValues = @{}
$WslDefaultParameterValues["grep"] = "--color"
$WslDefaultParameterValues["ls"] = "--color"
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
# Check if ssh-agent has keys
$command = ssh-add -l
# And add them if not
if ($command -eq 'The agent has no identities.') {
$question = 'ssh-agent has no identities, add them now?'
$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
if ($decision -eq 0) {
ssh-add
}
}
# Temporary fix for oh-my-posh
# Clear-Host
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
],
"alwaysShowNotificationIcon": true,
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"experimental.rendering.forceFullRepaint": false,
"launchMode": "default",
"profiles":
{
"defaults":
{
"colorScheme": "One Full Dark",
"cursorShape": "bar",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "FiraCode Nerd Font",
"size": 11.0,
"weight": 450
},
"intenseTextStyle": "all",
"opacity": 99,
"useAcrylic": false
},
"list":
[
{
"commandline": "pwsh-preview.cmd -NoLogo",
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore"
},
{
"guid": "{d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}",
"hidden": false,
"name": "Ubuntu 22.04.2 LTS",
"source": "CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc"
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": true,
"name": "Command Prompt"
},
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": true,
"name": "Windows PowerShell"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": true,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{aab79973-318f-43b6-a9bc-b4096493753f}",
"hidden": false,
"name": "Nushell",
"source": "nu"
}
]
},
"schemes":
[
{
"background": "#0C0C0C",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#012456",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell Powershell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#151515",
"black": "#151515",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Full Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#282C34",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#282C34",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Half Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#383A42",
"brightBlue": "#0184BC",
"brightCyan": "#0997B3",
"brightGreen": "#50A14F",
"brightPurple": "#A626A4",
"brightRed": "#E45649",
"brightWhite": "#FAFAFA",
"brightYellow": "#C18401",
"cursorColor": "#FFFFFF",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "One Half Light",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#FFFFFF",
"white": "#FAFAFA",
"yellow": "#C18401"
},
{
"background": "#002B36",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#FFFFFF",
"cyan": "#2AA198",
"foreground": "#839496",
"green": "#859900",
"name": "Solarized Dark",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#FDF6E3",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#002B36",
"cyan": "#2AA198",
"foreground": "#657B83",
"green": "#859900",
"name": "Solarized Light",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#D3D7CF",
"green": "#4E9A06",
"name": "Tango Dark",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#FFFFFF",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#000000",
"cyan": "#06989A",
"foreground": "#555753",
"green": "#4E9A06",
"name": "Tango Light",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#300A24",
"black": "#171421",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#08458F",
"brightCyan": "#2C9FB3",
"brightGreen": "#26A269",
"brightPurple": "#A347BA",
"brightRed": "#C01C28",
"brightWhite": "#F2F2F2",
"brightYellow": "#A2734C",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#FFFFFF",
"green": "#26A269",
"name": "Ubuntu-22.04-ColorScheme",
"purple": "#881798",
"red": "#C21A23",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#A2734C"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#000080",
"brightBlack": "#808080",
"brightBlue": "#0000FF",
"brightCyan": "#00FFFF",
"brightGreen": "#00FF00",
"brightPurple": "#FF00FF",
"brightRed": "#FF0000",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFF00",
"cursorColor": "#FFFFFF",
"cyan": "#008080",
"foreground": "#C0C0C0",
"green": "#008000",
"name": "Vintage",
"purple": "#800080",
"red": "#800000",
"selectionBackground": "#FFFFFF",
"white": "#C0C0C0",
"yellow": "#808000"
}
],
"tabWidthMode": "equal",
"themes": [],
"useAcrylicInTabRow": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment