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
Meh
  • 363
  • 2
  • 7
  • 10

1 Answers1

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
stej
  • 186
  • 3