New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Using Write-Host in custom promt function causes prompt to break. #5630

pavelbraginskiy opened this Issue Dec 5, 2017 · 4 comments


None yet
3 participants

pavelbraginskiy commented Dec 5, 2017

Steps to reproduce

Set a custom prompt function that uses Write-Host in $PROFILE, which is commonly done to have colorful prompts.

# Here's the $PROFILE
function prompt
	Write-Host ">" -nonewline
	return ""

Expected behavior

Prompt appears as >

Actual behavior

Prompt appears as >PS>>. Upon entering text after the prompt, it changes to PS>. Hitting enter for the next command causes >PS>> to appear again.

Environment data

> $PSVersionTable
Name                           Value                                         
----                           -----                                         
PSVersion                      6.0.0-rc                                      
PSEdition                      Core                                          
GitCommitId                    v6.0.0-rc                                     
OS                             Linux 4.13.16-300.fc27.x86_64 #1 SMP Mon No...
Platform                       Unix                                          
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                       
PSRemotingProtocolVersion      2.3                                           
WSManStackVersion              3.0            

This comment has been minimized.

MaximoTrinidad commented Dec 5, 2017

I'm sure this is by design as you'll get the same results in Windows PowerShell. I would not recommend using Write-Host in the prompt option.

But, you could be creative and try something like this: (one of my old scripts)

function prompt
	## - This function will change the PS Console to enumerate each 
	##   line preventing long pathnames:
	if ($host.UI.RawUI.CursorPosition.Y -eq 0)
		"< $pwd > `n`r" + "PS [" + $host.UI.RawUI.CursorPosition.Y + "] > "
		"PS [" + $host.UI.RawUI.CursorPosition.Y + "] > "

At least, will give you some ideas.


This comment has been minimized.


markekraus commented Dec 5, 2017

I believe This is lzybkr/PSReadLine#468 and is a bug in PSReadLine that will be fixed in a future version.


This comment has been minimized.


markekraus commented Dec 6, 2017

@pavelbraginskiy a Pre-release of PSReadline has been added to the PS Gallery which fixes this issue:


This comment has been minimized.

pavelbraginskiy commented Dec 6, 2017

@markekraus Thanks a bunch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment