Skip to content

Instantly share code, notes, and snippets.

@pcostarg
Last active September 15, 2022 16:14
Show Gist options
  • Save pcostarg/c193b2cfc7587386e52e7ba9baf95b6d to your computer and use it in GitHub Desktop.
Save pcostarg/c193b2cfc7587386e52e7ba9baf95b6d to your computer and use it in GitHub Desktop.
windows Terminal and PowerShell customization
if ($Host.Name -eq 'ConsoleHost') {
Import-Module PSReadline
Set-PSReadLineOption -PredictionSource History
set-PSReadLineOption -PredictionViewStyle ListView
}
Import-Module -Name Terminal-Icons
$env:POSH_GIT_ENABLED = $true
Import-Module posh-git
oh-my-posh --init --shell pwsh --config "%LocalAppData%\Programs\oh-my-posh\themes\_ohmyposh-v1.omp.json" | Invoke-Expression #needs literal path, replace %LocalAppData%
Enable-PoshTransientPrompt
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": false,
"osc99": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
"segments": [
{
"type": "session",
"style": "diamond",
"foreground": "#ffffff",
"background": "#c386f1",
"leading_diamond": "",
"properties": {
"postfix": " ",
"display_host": false
}
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#193549",
"background": "#ffff66",
"leading_diamond": "",
"trailing_diamond": ""
},
{
"type": "shell",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#ffffff",
"background": "#0077c2",
"properties": {
"prefix": "  ",
"postfix": ""
}
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#ffffff",
"background": "#ff479c",
"properties": {
"prefix": "  ",
"style": "agnoster"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#193549",
"background": "#fffb38",
"properties": {
"display_status": true,
"display_stash_count": true,
"display_upstream_icon": true
}
},
{
"type": "dotnet",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#ffffff",
"background": "#6CA35E",
"leading_diamond": "",
"trailing_diamond": "",
"properties": {
"display_version": true,
"prefix": "  "
}
},
{
"type": "exit",
"style": "powerline",
"powerline_symbol": "",
"invert_powerline": false,
"foreground": "#ffffff",
"background": "#2e9599",
"leading_diamond": "",
"trailing_diamond": "",
"properties": {
"always_enabled": true,
"color_background": true,
"display_exit_code": false,
"error_color": "#f1184c",
"prefix": " "
}
}
]
},
{
"type": "prompt",
"alignment": "right",
"segments": [
{
"type": "ytm",
"style": "powerline",
"powerline_symbol": "\uE0B2",
"invert_powerline": true,
"foreground": "#111111",
"background": "#1BD760",
"properties": {
"prefix": " \uF167 ",
"paused_icon": " ",
"playing_icon": " "
}
},
{
"type": "time",
"style": "powerline",
"invert_powerline": true,
"leading_diamond": "\uE0B2",
"trailing_diamond": "\uE0B4",
"background": "#2e9599",
"foreground": "#111111"
}
]
},
{
"type": "prompt",
"alignment": "left",
"newline": true,
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#007ACC",
"properties": {
"prefix": "",
"text": "\uE602"
}
}
]
}
],
"transient_prompt": {
"background": "transparent",
"foreground": "#ffffff",
"template": "<[{{ now | date \"02-01 15:04\" }}]{{ .Shell}}> {{ .Path }}> "
}
}
winget install JanDeDobbeleer.OhMyPosh
Install-Module posh-git -Scope CurrentUser
Install-Module -Name PSReadLine -Force #needed because it comes preinstalled and cannot be updated. Also we need latest version for Listview Prediction
Install-Module -Name Terminal-Icons -Repository PSGallery
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment