4

Is it possible to somehow configure PowerShell to add a new line after executing a command? IronPython and other console programs which I use doesn't always finish it's output with a \n and because of that the PowerShell prompt will appear at the middle of the line.

This is what I get:

PS D:\Test> ipy test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
RuntimeError: *** ERROR ***PS D:\Test\bin>  <---------- MIDDLE OF LINE PROMPT

This is what I would like:

PS D:\Test> ipy test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
RuntimeError: *** ERROR ***
PS D:\Test\bin>                            <---------- NEW LINE PROMPT
6

You can create custom prompt function like this:

Set-Content function:\prompt { 
  if($Host.UI.RawUI.CursorPosition.X -eq 0) {'PS>'} else{"`nPS>"}
}

How to test it:

write-host 'this is test' -nonewline

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.