Skip to content

Instantly share code, notes, and snippets.

@andrew-rietz
Last active April 15, 2020 15:14
Show Gist options
  • Save andrew-rietz/2b908095524a64c31699c2afef292311 to your computer and use it in GitHub Desktop.
Save andrew-rietz/2b908095524a64c31699c2afef292311 to your computer and use it in GitHub Desktop.

Customizing Your Powershell

Create a Powershell Profile

  1. Check if a profile already exists:
    Test-Path $profile
  2. If the result was 'False' then you don't have a profile yet. Create one:
    New-Item -path $profile -type file –force
    Reference: https://www.howtogeek.com/50236/customizing-your-powershell-profile/

Change the Default Background Color

  1. Right click on the powershell menu bar --> Properties
  2. Go to the 'Colors' tab
  3. Edit your background color. I chose a dark grey (RGB = 39, 40, 34)

Adding Git Branch Info to the Profile

  1. You'll need to add a couple functions to your profile. See reference below.
  2. Once you've added the functions, feel free to change the color assignments (I changed the color for the branch name from "green" to "cyan" because it shows up better on my background)
    Reference: https://stackoverflow.com/a/44411205

Get a List of Color Options in Powershell

$colors = [enum]::GetValues([System.ConsoleColor])
Foreach ($bgcolor in $colors){
    Foreach ($fgcolor in $colors) { Write-Host "$fgcolor|"  -ForegroundColor $fgcolor -BackgroundColor $bgcolor -NoNewLine }
    Write-Host " on $bgcolor"
}

Reference: https://stackoverflow.com/a/41954792

Changing your Default Git Colors

  1. Add the following to your .gitconfig:
[color]
    ui = true
[color "status"]
    changed = red bold
    untracked = red bold
    added = green bold

Reference: https://stackoverflow.com/a/22954951

Further Reading

https://spin.atomicobject.com/2019/05/09/powershell-tools/

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