Skip to content

Instantly share code, notes, and snippets.

@Linhieng
Last active August 26, 2023 06:28
Show Gist options
  • Save Linhieng/092192b87a23e9c53f77249f14e267dd to your computer and use it in GitHub Desktop.
Save Linhieng/092192b87a23e9c53f77249f14e267dd to your computer and use it in GitHub Desktop.
PowerShell prompt string
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"newline": true,
"segments": [
{
"background": "#ffffff",
"foreground": "#61AFEF",
"leading_diamond": "\u256d\u2500\ue0b2",
"style": "diamond",
"template": " \uf007 {{ .HostName }} ",
"trailing_diamond": "\ue0b0",
"type": "session"
},
{
"background": "#91ddff",
"foreground": "#100e23",
"powerline_symbol": "\ue0b0",
"properties": {
"folder_icon": "\uf115",
"folder_separator_icon": " \ue0b1 ",
"style": "full"
},
"style": "powerline",
"template": " {{ .Path }} ",
"type": "path"
}
],
"type": "prompt"
},
{
"alignment": "right",
"segments": [
{
"background": "#e4e4e4",
"foreground": "#585858",
"properties": {
"style": "austin",
"always_enabled": true
},
"invert_powerline": true,
"style": "powerline",
"powerline_symbol": "\ue0b2",
"template": " \ueba2 {{ .FormattedMs }} ",
"type": "executiontime"
}
],
"type": "prompt"
},
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#FFFF00",
"style": "plain",
"template": "\u2570\u2500\ue285",
"type": "text"
}
],
"type": "prompt"
}
],
"final_space": true,
"version": 2
}
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#FFFF00",
"style": "plain",
"template": "\u256d\u2500",
"type": "text"
},
{
"foreground": "#ffffff",
"style": "plain",
"properties": {
"folder_separator_icon": "/",
"style": "full"
},
"template": " {{ .Path }} ",
"type": "path"
}
],
"type": "prompt"
},
{
"alignment": "right",
"segments": [
{
"background": "#e4e4e4",
"foreground": "#585858",
"properties": {
"style": "austin",
"always_enabled": true
},
"invert_powerline": true,
"style": "powerline",
"powerline_symbol": "\ue0b2",
"template": " \uf0e7 {{ .FormattedMs }} ",
"type": "executiontime"
}
],
"type": "prompt"
},
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#FFFF00",
"style": "plain",
"template": "\u2570\u2500\ue285",
"type": "text"
}
],
"type": "prompt"
}
],
"final_space": true,
"version": 2
}
function prompt {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = [Security.Principal.WindowsPrincipal] $identity
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
$fullpath = (Get-Location) -replace "\\", "/"
if($principal.IsInRole($adminRole)) {
([System.Environment]::NewLine) + "[Admin] " + "$([char]0x1b)[92m" + "$fullpath" + "$([char]0x1b)[91m" + ([System.Environment]::NewLine) + "> "
} else {
([System.Environment]::NewLine) + "$([char]0x1b)[92m" + "$fullpath" + "$([char]0x1b)[91m" + ([System.Environment]::NewLine) + "> "
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment