Skip to content

Instantly share code, notes, and snippets.

@griffeth-barker
Created June 1, 2025 17:24
Show Gist options
  • Save griffeth-barker/763b73eb424596b1913d50aec0906f23 to your computer and use it in GitHub Desktop.
Save griffeth-barker/763b73eb424596b1913d50aec0906f23 to your computer and use it in GitHub Desktop.
Colorful PowerShell Prompt
<#
.SYNOPSIS
A colorful PowerShell prompt.
.DESCRIPTION
This function replaces your default PowerShell prompt with a colorful one.
The format of the prompt looks like this: `username@hostname:[C:\Users\griff.systems\Documents]>`
Each new command line gets a random console color from the available default console colors.
You can add this to your `$profile` to use the custom prompt.
.NOTES
Not compatible with oh-my-posh.
Requirements:
- Operating System(s):
- "Windows"
- Package(s):
- "PowerShell"
License:
This function is released under the MIT License.
https://choosealicense.com/licenses/mit/
.LINK
https://gist.github.com/griffeth-barker/763b73eb424596b1913d50aec0906f23
#>
function prompt {
$promptParts = @(
"$(($env:USERNAME).ToLower())",
"@",
"$(($env:COMPUTERNAME).ToLower())",
":",
"[",
"$($(Get-Location).Path.ToLower())",
"]"
)
$promptColor = Get-Random -Minimum 1 -Maximum 15
Write-Host "$($promptParts -join '')" -ForegroundColor $promptColor -NoNewLine
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment