Skip to content

Instantly share code, notes, and snippets.

@bgelens

bgelens/ben.json

Last active Mar 22, 2021
Embed
What would you like to do?
My oh-my-posh v3 theme!
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": false,
"console_title": false,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
"segments": [
{
"type": "envvar",
"style": "powerline",
"foreground": "#007ACC",
"background": "#000000",
"properties": {
"var_name": "oh_my_psversion",
"postfix": " \uFCB5 ",
"prefix": ""
}
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#100e23",
"background": "#ffe9aa",
"leading_diamond": "",
"trailing_diamond": "",
"properties": null
},
{
"type": "envvar",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#0077c2",
"properties": {
"var_name": "oh_my_azure_context",
"prefix": "\uFD03 "
}
},
{
"type": "kubectl",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#000000",
"background": "#ebcc34",
"properties": {
"prefix": "\uFD31 ",
"template": "{{.Context}}{{if .Namespace}} - {{.Namespace}}{{end}}"
}
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#100e23",
"background": "#91ddff",
"leading_diamond": "",
"trailing_diamond": "",
"properties": {
"style": "folder",
"prefix": "\uF115 ",
"postfix": " "
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#193549",
"background": "#95ffa4",
"leading_diamond": "",
"trailing_diamond": "",
"properties": {
"display_stash_count": true,
"stash_count_icon": "\uF692 ",
"prefix": ""
}
},
{
"type": "exit",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#ffffff",
"background": "#ff8080",
"leading_diamond": "",
"trailing_diamond": "",
"properties": null
}
]
},
{
"type": "newline"
},
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#007ACC",
"properties": {
"prefix": "",
"text": "\u276F"
}
}
]
}
]
}
#requires -Module Microsoft.PowerShell.UnixCompleters
$env:PATH = "/usr/local/opt/python/libexec/bin:/usr/local/opt/openjdk/bin:/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/MacOS:$env:PATH"
Set-PSReadLineOption -EditMode Emacs -BellStyle None -ExtraPromptLineCount 1 -PredictionSource History -Colors @{
Selection = "`e[93m"
}
Set-PSReadLineKeyHandler -Chord Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key 'Ctrl+f' -Function ForwardWord
Set-PSReadLineKeyHandler -Key 'Ctrl+z' -Function Undo
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
function Set-EnvVar {
if (Test-Path -Path ~/.Azure/AzureRmContext.json) {
$azureContext = Get-Content ~/.Azure/AzureRmContext.json | ConvertFrom-Json
$subscriptionName = $azureContext.Contexts.($azureContext.DefaultContextKey).Subscription.Name
$env:oh_my_azure_context = $subscriptionName
} else {
$env:oh_my_azure_context = $null
}
$env:oh_my_psversion = ($PSVersionTable.PSVersion.ToString() -split '-')[0]
}
Set-PoshPrompt -Theme ~/.config/powershell/PoshThemes/ben.json
New-Alias -Name 'Set-PoshContext' -Value 'Set-EnvVar' -Scope Global
@bgelens

This comment has been minimized.

Copy link
Owner Author

@bgelens bgelens commented Oct 22, 2020

image

Font: Caskaydia Cove Nerd Font

brew tap homebrew/cask-fonts
brew cask install font-caskaydia-cove-nerd-font

Make sure you change the line in the profile where the theme is loaded to point to your path (note I got a report on Windows that the ~ did not work correctly so you might want to use a literal path):

Set-PoshPrompt -Theme ~\.config\powershell\themes\ben.json
@markscholman

This comment has been minimized.

Copy link

@markscholman markscholman commented Oct 22, 2020

And you need to install PSReadline prerelease as well!
Install-Module PSReadLine -AllowPrerelease -Force

@bgelens

This comment has been minimized.

Copy link
Owner Author

@bgelens bgelens commented Oct 22, 2020

Yes, for those settings indeed (copied a little bit too much profile :)) I'll leave it in there for reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment