Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MS windows powershell promt, (without git)
# Import module from previous step
Import-Module -Name posh-git
function Test-Administrator {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
function mklink { cmd /c mklink $args }
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
Write-Host
# Reset color, which can be messed up by Enable-GitColors
#$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
#$Host.UI.RawUI.BackgroundColor = "Black"
if (Test-Administrator) { # Use different username if elevated
Write-Host "(Elevated) " -NoNewline -ForegroundColor White
}
Write-Host "$ENV:USERNAME@" -NoNewline -ForegroundColor White -BackgroundColor DarkGreen
Write-Host "$ENV:COMPUTERNAME" -NoNewline -ForegroundColor White -BackgroundColor DarkGreen # -ForegroundColor Magenta
if ($s -ne $null) { # color for PSSessions
Write-Host " (`$s: " -NoNewline -ForegroundColor DarkGray
Write-Host "$($s.Name)" -NoNewline -ForegroundColor Yellow
Write-Host ") " -NoNewline -ForegroundColor DarkGray
}
Write-Host ":" -NoNewline -ForegroundColor DarkGray
Write-Host $($(Get-Location) -replace ($env:USERPROFILE).Replace('\','\\'), "~") -NoNewline -ForegroundColor Magenta
Write-Host " (" -NoNewline -ForegroundColor Gray
#Write-Host (Get-Date -Format G) -NoNewline -ForegroundColor DarkMagenta
Write-Host (Get-Date -Format G) -NoNewline -ForegroundColor Gray
Write-Host ")" -NoNewline -ForegroundColor Gray
$global:LASTEXITCODE = $realLASTEXITCODE
Write-VcsStatus
Write-Host ""
return "> "
}
Set-Alias ls Get-ChildItemColor -option AllScope -Force
Set-Alias ll Get-ChildItemColor -option AllScope -Force
Set-Alias dir Get-ChildItemColor -option AllScope -Force
@SunnyBingoMe

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.