Tuesday, September 27, 2016

Customizing the PowerShell prompt

By default, the PowerShell prompt is PS followed by the current directory, followed by a greater-than sign. That can easily be changed, however, by defining a function called Prompt. Such a function takes no arguments, and its return value is used as the text to display as the prompt. It can take other actions too, like setting the window title. It's likely that you would want to place that function in your PowerShell profile script rather than retyping it every time.

For example, this removes the current directory from the prompt:

Function Prompt {
  'PS> '
}

No comments:

Post a Comment