Thursday, October 31, 2019

Nice Powershell prompt

Here is a nice Powershell prompt

$str= @'
Set-Item -Path function:prompt -Value {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
$color=if ((New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) {"Red"} else {"Cyan"}

$promptString = 'PS '+ (Get-History).Id[-1] + " "+ $(Get-Date -Format t) + " " + $(Get-Location) + '> '
Write-Host $promptString -NoNewline -ForegroundColor $color
return " "

}
'@

Set-Content $PSHome\Profile.ps1 -Value $str                           

Output:

PS 36 09:33 C:\>

Other option:
https://raw.githubusercontent.com/thomasrayner/dev-workstation/master/prompt.ps1

Install any font from https://github.com/ryanoasis/nerd-fonts and use it in conemu.

No comments:

Post a Comment