11.4. Changing the Prompt Settings

All shells that I have seen, cmd.exe and UNIX shells included, have a mechanism to change the prompt string that gets displayed to the user before a command executes. Those shells allow users to configure the prompt by setting a global or an environment variable. For example, the cmd.exe default prompt has the $P$G value, where $P makes the shell print the current drive and path and $G prints the greater-than, or >, sign. The documentation lists several other options, all starting with a dollar sign, that one can use. UNIX shells, such as bash, offer a lot more options, but in essence, the approach is the same, including options and literal strings in a global variable. This approach has several disadvantages: ...

Get Pro Windows PowerShell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.