5

Is it possible to redefine the prompt function specified in the user's profile after the shell has started?

2 Answers 2

4

To change the prompt function at any time, just execute a statement like the following at the PowerShell command line:

function prompt { "$env:computername $pwd>" }
Sign up to request clarification or add additional context in comments.

Comments

3

Yes, just enter code as normal:

function prompt
{
    $random = new-object random
    $color=[System.ConsoleColor]$random.next(1,16)
    Write-Host ("PS " + $(get-location) +">") -nonewline -foregroundcolor $color
    return " "
}

(credit to http://mshforfun.blogspot.com/2006/05/perfect-prompt-for-windows-powershell.html)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.