Skip to content

Instantly share code, notes, and snippets.

@branneman
Last active August 29, 2015 13:57
Show Gist options
  • Save branneman/9660173 to your computer and use it in GitHub Desktop.
Save branneman/9660173 to your computer and use it in GitHub Desktop.
Powershell custom prompt & some coloring. Here's how it looks: http://bran.name/dump/powershell-prompt.png
# Aliasses
Set-Alias l ls
Set-Alias e explorer
# Force coloring of git and npm commands
$env:TERM = 'cygwin' # windows-ansi | cygwin
$env:LESS = 'FRSX'
#
# Custom prompt
#
# bran at ubuntu in ~/Source/techradar on docker node v0.11.12
# $ _
#
function prompt
{
# Grab git branch
$git_string = "";
git branch | foreach {
if ($_ -match "^\* (.*)") {
$git_string += $matches[1]
}
}
# User (orange)
Write-Host ("")
Write-Host ([Environment]::UserName) -nonewline -foregroundcolor DarkRed
# Host (yellow)
Write-Host (" at ") -nonewline -foregroundcolor White
Write-Host ([System.Net.Dns]::GetHostName().ToLower()) -nonewline -foregroundcolor DarkYellow
# Dir (green)
Write-Host (" in ") -nonewline -foregroundcolor White
Write-Host ($(get-location)) -nonewline -foregroundcolor DarkGreen
# Git (purple)
if ($git_string) {
Write-Host (" on ") -nonewline -foregroundcolor White
Write-Host ($git_string) -nonewline -foregroundcolor Cyan
}
# Node (cyan)
if (Test-Path ".\package.json") {
Write-Host (" node ") -nonewline -foregroundcolor White
Write-Host (node -v) -nonewline -foregroundcolor Blue
}
Write-Host ("")
Write-Host ("λ") -nonewline -foregroundcolor White
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment