Created
June 1, 2025 17:24
-
-
Save griffeth-barker/763b73eb424596b1913d50aec0906f23 to your computer and use it in GitHub Desktop.
Colorful PowerShell Prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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