Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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