Skip to content

Instantly share code, notes, and snippets.

@richorama
Last active March 17, 2017 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richorama/f318a9c3a024e36357369e36d200638a to your computer and use it in GitHub Desktop.
Save richorama/f318a9c3a024e36357369e36d200638a to your computer and use it in GitHub Desktop.
Microsoft.PowerShell_profile.ps1
#requires -Module @{ModuleName="PSGit"; ModuleVersion="2.0.4"}, @{ModuleName="PowerLine"; ModuleVersion="2.0.0"}
using module PowerLine
using namespace PowerLine
$PowerLinePrompt = 1,
(
$null, # No left-aligned content on this line
@(
@{ text = { New-PowerLineBlock (Get-Elapsed) -ErrorBackgroundColor DarkRed -ErrorForegroundColor White -ForegroundColor Black -BackgroundColor DarkGray } }
@{ bg = "Gray"; fg = "Black"; text = { Get-Date -f "T" } }
)
), @(
@{ bg = "Green"; fg = "White"; text = { [PowerLine.Prompt]::Gear * $NestedPromptLevel } }
@{ bg = "Green"; fg = "White"; text = { if($pushd = (Get-Location -Stack).count) { "$([char]187)" + $pushd } } }
@{ bg = "DarkGray"; fg = "White"; text = { $pwd } }
# PSGit is still in early stages, but it has PowerLine support
@{ text = { Get-GitStatusPowerline } }
)
Set-PowerLinePrompt -CurrentDirectory -PowerlineFont:(!$SafeCharacters) -Title { "PowerShell - {0} ({1})" -f (Convert-Path $pwd), $pwd.Provider.Name }
# As a bonus, here are the settings I use for my PSGit prompt:
Set-GitPromptSettings -SeparatorText '' -BeforeText '' -BeforeChangesText '' -AfterChangesText '' -AfterNoChangesText '' `
-BranchText "$([PowerLine.Prompt]::Branch) " -BranchForeground White -BranchBackground Green `
-BehindByText '▼' -BehindByForeground White -BehindByBackground DarkGreen `
-AheadByText '▲' -AheadByForeground White -AheadByBackground DarkGreen `
-StagedChangesForeground White -StagedChangesBackground DarkBlue `
-UnStagedChangesForeground White -UnStagedChangesBackground Blue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment