Last active
March 13, 2022 08:48
-
-
Save acast15/5dc2158dddf78af8427c7f8a6dc08d2d to your computer and use it in GitHub Desktop.
Add this function to your PowerShell profile so you won't see the full path of the working directory on the prompt. Once you've configured your profile, restart PowerShell and try any of the options for the prompt.
This file contains 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
function demo { | |
param ( | |
[parameter()] | |
[ValidateSet('v', 'n', 'r')] | |
[string]$Option = 'v' | |
) | |
switch ($Option) { | |
# hide PS version | |
'n' { | |
function global:prompt { "PS > " } | |
} | |
# reset prompt | |
'r' { | |
function global:prompt { "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) " } | |
} | |
# show PS version | |
'v' { | |
function global:prompt { "PS$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor) > " } | |
} | |
} | |
} | |
# Change prompt to "PS [version] >" | |
#demo demo v | |
# Change prompt to "PS >" | |
#demo n | |
# Reset prompt | |
#demo r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment