Powershell: Linux: When Prompt include Unicode Char, Cursor Positioned Error

Created on 11 Jan 2018  路  5Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

cd /tmp
mkdir 娴嬭瘯璺緞
cd 娴嬭瘯璺緞

Expected behavior

Actual behavior

2018-01-11 10-10-36

2018-01-11 10-16-56

Environment data

> $PSVersionTable
Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      6.0.0                                                                                   
PSEdition                      Core                                                                                    
GitCommitId                    v6.0.0                                                                                  
OS                             Linux 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017              
Platform                       Unix                                                                                    
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 
WSManStackVersion              3.0                                                                                     

This problem is due to the fact that the character length is not calculated correctly. UTF-8 encoding, the length of the character may be 1~4 bytes. So the cursor is not positioned correctly.

Issue-Question Resolution-Answered

Most helpful comment

@rkeithhill and anyone else - the PSGallery team have kindly updated the back end, so PSReadLine 2.0 should now install correctly on Linux/Mac w/o needing to rename the directory.

All 5 comments

Run Install-Module PSReadLine -AllowPrerelease -Force -AllowClobber to get 2.0.0-beta1 with the fix.

PowerShell 6.1 will soon pull this version as well, see https://github.com/PowerShell/PowerShell/pull/5759

If you're running on Linux, you might need to rename the install directory to fix the case, I think it gets installed with PSReadline instead of PSReadLine. I'm looking in to how that can be fixed.

Ah, then ignore my comment - https://github.com/lzybkr/PSReadLine/issues/555#issuecomment-357033986, Ah yup, this command sudo mv /usr/local/share/powershell/Modules/PSReadline/ /usr/local/share/powershell/Modules/PSReadLine/ fixed it for me.

@rkeithhill and anyone else - the PSGallery team have kindly updated the back end, so PSReadLine 2.0 should now install correctly on Linux/Mac w/o needing to rename the directory.

@lzybkr OK fixed.

@chuanjiao10 - that's definitely a bug, go ahead and open an issue in the PSReadLine repo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manofspirit picture manofspirit  路  3Comments

SteveL-MSFT picture SteveL-MSFT  路  3Comments

pcgeek86 picture pcgeek86  路  3Comments

alx9r picture alx9r  路  3Comments

JohnLBevan picture JohnLBevan  路  3Comments