question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prompt function with Write-Host on MacOS 10.12.5

See original GitHub issue

Steps to reproduce

When overwriting the prompt function as follows:

function prompt {
    Write-Host "Something> "
    " "
}

The reason why one would want to manually use Write-Host for outputting prompt values, is to be able to use colors. This is done in posh-git for example. In windows this works as expected.

Expected behavior

Something> --input goes here--

Actual behavior

Something>
 Something>
--cursor position--

When i start typing the input appears as follows:

Something>
--input appears here--

Environment data

> $PSVersionTable
Name                           Value                                           
----                           -----                                           
PSVersion                      6.0.0-beta                                      
PSEdition                      Core                                            
BuildVersion                   3.0.0.0                                         
CLRVersion                                                                     
GitCommitId                    v6.0.0-beta.1                                   
OS                             Darwin 16.6.0 Darwin Kernel Version 16.6.0: F...
Platform                       Unix                                            
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
PSRemotingProtocolVersion      2.3                                             
SerializationVersion           1.1.0.1                                         
WSManStackVersion              3.0 

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jpograncommented, Jul 11, 2017

FWIW, on beta.3 this is still an issue. This shows up on Terminal.app and iterm2 with just PSReadline and the example prompt in this issue. Things are resolved if PSReadline module is removed, but all history, tab completing, etc functionality is gone (obviously).

PowerShell v6.0.0-beta.3
Copyright (C) Microsoft Corporation. All rights reserved.

PS /Users/jpogran> function prompt {                                                                                                   >>     Write-Host "Something> "                                                                                                        >>     " "                                                                                                                             >> }
Something>
 Something>
Something>
 "foo"
foo
Something>
 $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.3
OS                             Darwin 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELE...
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


Something>
 Something>

0reactions
stuartleekscommented, Nov 22, 2017

Ah, ok… I missed the initial PSReadline reference - thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

macos - I typed () in terminal and got a prompt. What is it for?
I realized I can type any gibberish anygibberish() and also get the prompt. If you continue to type () at the function> prompt,...
Read more >
Restore the Desktop Discord Client on OS X 10.9 - macOS ...
To make the process of restoring Desktop client functionality very easy, I've written a small Python program (10.9+, no need to use a...
Read more >
Command Line – Page 8
Posts about Command Line written by ab. ... On macOS the host keys are stored in /private/etc/ssh/ along with some other files required...
Read more >
macOS – SSH Error 'No Matching Exchange Method Found'
Mac SSH error Problem seen after upgrading macOSX to Sierra, where Open SSH Version 7 stops you communicating with devices using RSA SHA1...
Read more >
macOS 10.13 High Sierra on ESXi 6.5 | iThinkVirtual™
It will prompt for your password since you are using "sudo". You will not be able to see what you type nor will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found