Skip to content

Instantly share code, notes, and snippets.

@alejofv
Last active August 14, 2019 04:07
Show Gist options
  • Select an option

  • Save alejofv/af7b1f3e5d2f63bfd78a0ec63686e82a to your computer and use it in GitHub Desktop.

Select an option

Save alejofv/af7b1f3e5d2f63bfd78a0ec63686e82a to your computer and use it in GitHub Desktop.
Powershell profile using Powerline prompt
Import-Module Powerline
function Get-PushedLocationCount {
if ($pushed = (Get-Location -Stack).Count) { New-PromptText " »$pushed " -BackgroundColor "#00af87" -ForegroundColor "#000000" }
}
function Get-GitBranchName {
if (Get-Command git -ErrorAction SilentlyContinue) {
if ($(git rev-parse --is-inside-work-tree 2>$null)) {
$branch = $(git symbolic-ref HEAD 2>$null).ToString().Substring(11)
# Implement status checks using https://gist.github.com/VojtechStep/9d2478a63c2c626c0173527b2f86f370
New-PromptText " $branch " -BackgroundColor "#AFD700" -ForegroundColor "000000"
}
}
}
function Get-SpacedPath {
$paths = ((Get-SegmentedPath) -join " \ ")
New-PromptText " $paths " -BackgroundColor "#3A3A3A"
}
$prompt = @(
{ New-PromptText " PS " -BackgroundColor "#0087AF" -ForegroundColor "#FFFFFF" }
{ Get-SpacedPath }
{ Get-PushedLocationCount }
{ Get-GitBranchName }
{ New-PromptText " > " -BackgroundColor "#303030" -ErrorBackgroundColor "#D7005F" -ForegroundColor "#FFFFFF" }
)
Set-PowerLinePrompt -HideError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment