Skip to content

Instantly share code, notes, and snippets.

@seangenabe
Last active April 3, 2016 09:32
Show Gist options
  • Save seangenabe/e6c8052ee283a468f5831e34ce1e534a to your computer and use it in GitHub Desktop.
Save seangenabe/e6c8052ee283a468f5831e34ce1e534a to your computer and use it in GitHub Desktop.
powershell profile
*.ps1 text eol=crlf
Set-PSReadlineOption -TokenKind Comment Green
Set-PSReadlineOption -TokenKind Keyword Blue
Set-PSReadlineOption -TokenKind String Red
Set-PSReadlineOption -TokenKind Operator Gray
Set-PSReadlineOption -TokenKind Variable Magenta
Set-PSReadlineOption -TokenKind Command Cyan
Set-PSReadlineOption -TokenKind Parameter Yellow
Set-PSReadlineOption -TokenKind Type DarkCyan
$host.PrivateData.ErrorForegroundColor = "red"
$host.PrivateData.ErrorBackgroundColor = "darkgray"
$host.PrivateData.VerboseForegroundColor = "blue"
$host.PrivateData.VerboseBackgroundColor = "darkgray"
$host.PrivateData.WarningForegroundColor = "yellow"
$host.PrivateData.WarningBackgroundColor = "darkgray"
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
Import-Module "C:\Users\Sean\Documents\WindowsPowerShell\Modules\posh-git"
function global:prompt {
$realLASTEXITCODE = $LASTEXITCODE
$h = ($env:HOME).ToString().Replace('\', '\\')
$loc = $pwd.ProviderPath
$pref = ''
$highlighted = ''
$regex1 = new-object Regex("$h\\documents\\projects\\([^\\]*)(.*)", "IgnoreCase")
$match1 = $regex1.Match($loc)
if ($match1.Success) {
$highlighted = $match1.Groups[1].Value
$loc = $match1.Groups[2].Value
}
$regex2 = new-object Regex("$h(\\?.*)", "IgnoreCase")
$match2 = $regex2.Match($loc)
if ($match2.Success) {
$pref = "~"
$loc = $match2.Groups[1].Value
}
Write-Host $highlighted -ForegroundColor blue -nonewline
Write-Host $pref -foregroundcolor yellow -nonewline
Write-Host $loc -nonewline
$Admin = ''
$CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object System.Security.Principal.WindowsPrincipal($CurrentUser)
if ($principal.IsInRole("Administrators")) { $Admin = ' A' }
Write-Host $Admin -foregroundcolor red -noNewLine
Write-VcsStatus
$global:LASTEXITCODE = $realLASTEXITCODE
Write-Host
return "> "
}
Pop-Location
Start-SshAgent -Quiet > $null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment