Skip to content

Instantly share code, notes, and snippets.

@emaldonadot
Created October 3, 2019 15:16
Show Gist options
  • Save emaldonadot/83ef18b1f8415be86b6515cf6df029ef to your computer and use it in GitHub Desktop.
Save emaldonadot/83ef18b1f8415be86b6515cf6df029ef to your computer and use it in GitHub Desktop.
Make PowerShell look better

This changes the way your prompt looks in powershell giving a more "linuxish" feel.

function prompt {
    $realLASTEXITCODE = $LASTEXITCODE

    Write-Host
  

    Write-Host "$ENV:USERNAME@" -NoNewline -ForegroundColor DarkYellow
    Write-Host "$ENV:COMPUTERNAME" -NoNewline -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 Blue
    Write-Host " : " -NoNewline -ForegroundColor DarkGray
    Write-Host (Get-Date -Format G) -NoNewline -ForegroundColor DarkMagenta
    Write-Host " : " -NoNewline -ForegroundColor DarkGray

    $global:LASTEXITCODE = $realLASTEXITCODE

    Write-VcsStatus

    Write-Host ""

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