You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Home, End, Ctr+Arrow don't work (Arch/Linux 4.20) #8869
I'm pretty sure this is a PowerShell problem and probably not a PSReadLine problem. FWIW, I only see this when I SSH into our RedHat or Ubuntu build machines. I don't see this issue in Bash but I do see it when I then start up pwsh. I also see it when I start pwsh with pwsh -noprofile -noni which, I think, doesn't load PSReadLine. I see this when using both conhost and WindowsTerminal. And it is somewhat maddening TBH.
This shows the issue on 6.2.2 but I just tried PS7-preview.3 and it behaves the exact same way.
Is there any chance to fix this. I would even try to do it myself since bash is maddeningly hard to do even easiest thing but I cannot swap pwsh because it lacks that little things like arrow keys support :)
I'm slightly preplexed by these comments. This is an issue that is stabely reproducible in powershell and it does not seem to be and obvious way to reporoduce it in a C# console app. Also it does not seem that there is any evidence is given that it is not a Powershell issue.
Steve Lee (@SteveL-MSFT) thank you for this. Will I be too far off if I conjecture, that these services (Home, End, Ctr+Arrow ) are not provided by ReadLine itself, but by something else, for example on windows by console host?
Steven Willard II (@steven-willard) yep, it's still broken. If you read the issue history, it seems pretty impossible to get stuff fixed here, and this is not just this issue, it's general attitude towards the community, e.g read this or this. I personally abandoned any hope of this being fixed and moved on.
PS on Linux is just broken and looks line maintainers want it to work this way. It would be nice to have the same CLI for both OSes but it looks line it won't be PS.
I think it would be easier to use bash via CygWin or something similar than PS on Linux.
They should be just honest and kill it instead of lie to people that is 'cross-platform'.
Yep. I've been watching this thread for 2 years, lately mainly for fun and kicks. There should be banner:
abandon hope all ye who enter here
Yes, it's a pity... In this case (as far as i can tell) Powershell team and .NET team are playing "pass the buck" on each other.
PS on Linux is just broken and looks line maintainers want it to work this way. It would be nice to have the same CLI for both OSes but it looks line it won't be PS.
Which is very sad, because PS is more powerful than bash in many ways.
I think it would be easier to use bash via CygWin or something similar than PS on Linux.
No need to use CygWin since WSL and WSL2. In fact i found myself using bash on Windows more and more, because using PS on Linux isn't that easy as promised...
There are too many comments in this thread... I cannot figure it out, why was the issue closed?
Home, Ctrl + Arrow are still not working in pwsh on linux.
“@PowerShell_Team How come issue with broken Home, End keys not working on Linux is closed? (https://t.co/suSQ9qGTDw). Issue is still there and seems to be lying with Microsoft to fix and result of finger-pointing within MS who will do it”
That PSReadLine doesn't offer this behavior by default appears to be intentional, see PowerShell/PSReadLine#668.
Instead (as yodasad noted) there are Ctrl+a and Ctrl+e for beginning / end of line, as well as alt-b and alt-f for backward word / forward word. Those are Emacs conventions, apparently, but that's where I'm out of my depth.
Reacted by GSA, Bo Søborg Petersen and Stephen Meech
This did not work for me from command line, I'm on 7.2.1 and Ubuntu 20.04.3 LTS (Focal Fossa) and I just executed those from command line instead of $PROFILE to test
Hmm, I'm on 7.2.1 / 20.04 too, and it works directly on command line as well as in profile.ps1.
An alternative that works for me as well is:
Set-PSReadLineOption-EditMode Windows
The default EditMode on Linux appears to be Emacs, see also here for a (presumably) comprehensive list of things that should work in different edit modes. It's a nice reference.
If that also doesn't work, then the only idea I have left - and that's a wild guess - is that the keys are hijacked by something else. That sometimes happens to me with shortcuts on Linux, but it would be weird with Home and End.
You could try (if you haven't already) [Console]::ReadKey() followed by Home / End, and see what happens, and if it tells you anything.
Reacted by Gonkers, Victor Borges and Avasam
Reacted by Aaron, Gonkers, Victor Borges, Tim Elmer, matefriedl, Avasam, Pedro Paulo Vezza Campos and DavidBeh
Reacted by Aaron, Nati Sayada, Daniel Tang and fkucharczyk
Issue was seen only when using Remote Desktop Manager, not present at Windows command line, otherwise solution by Thomas Hepp (@hepptho) works as expected
Thomas Hepp (@hepptho) RE Set-PSReadLineOption -EditMode Windows - thanks for that!!! I can't believe what a dope I've been. I've been fighting the PSRL key bindings on Linux/macOS for a while now. But my main machine is Windows. For some reason, it never occurred to me to check/change the PSRL edit mode. 🤦♂️
If that also doesn't work, then the only idea I have left - and that's a wild guess - is that the keys are hijacked by something else. That sometimes happens to me with shortcuts on Linux, but it would be weird with Home and End. You could try (if you haven't already) [Console]::ReadKey() followed by Home / End, and see what happens, and if it tells you anything.
That was already done at the beginning of this thread on Sep, 2, 2019: #8869 (comment)
It seems like pressing the Home button results in Escape following "H" and pressing the End button results in Escape following F, so I tried to do this:
And it works, Home and End buttons started to work as expected, but unfortunately after that I cannot type capital "H" and "F" pressing Shift+H and Shift+F, they started to act as if I press Home and End buttons moving the cursor to the Beginning and the End of line.
None of the above worked for me on Mac (PS 7.2.2) but this did - hope it helps someone else.
Create a new Terminal profile (or copy an existing) and add a Keyboard mapping for Home and End:
Home
Key: Home
Modifier: None
Send text: (using Mac keyboard, not external): CTRL+A
This should produce Send text of \001
End:
Key: End
Modifier: None
Send text: (again on Mac keyboard, assuming no other modifier key changes): CTRL+E
This should produce Send text of \005
Activity
[-]My bug report[/-][+]Home, End, Ctr+Arrow don't work (Arch/Linux 4.20)[/+]lzybkr commentedon Feb 13, 2019
This is most likely not a PowerShell problem.
Try
[Console]::ReadKey()then type Home. Output should look like:I'm guessing it won't, in which case the problem could be with:
$env:TERMrkeithhill commentedon Sep 2, 2019
Jason Shirk (@lzybkr) This is what I see on Ubuntu 18.04 (when I ssh in from Windows PS 7 and then start pwsh):
This is a real bummer as it makes moving around a command line painful. Here's the term info:
rkeithhill commentedon Sep 9, 2019
I'm pretty sure this is a PowerShell problem and probably not a PSReadLine problem. FWIW, I only see this when I SSH into our RedHat or Ubuntu build machines. I don't see this issue in Bash but I do see it when I then start up pwsh. I also see it when I start pwsh with
pwsh -noprofile -noniwhich, I think, doesn't load PSReadLine. I see this when using both conhost and WindowsTerminal. And it is somewhat maddening TBH.This shows the issue on 6.2.2 but I just tried PS7-preview.3 and it behaves the exact same way.
npodbielski commentedon Sep 14, 2019
Is there any chance to fix this. I would even try to do it myself since bash is maddeningly hard to do even easiest thing but I cannot swap pwsh because it lacks that little things like arrow keys support :)
iSazonov commentedon Sep 29, 2019
/cc Dongbo Wang (@daxian-dbw) Steve Lee (@SteveL-MSFT) If the problem is in .Net Core we need to get a fix before .Net Core 3.1 LTS.
Keith Hill (@rkeithhill) Could you please make the test with simple C# app which only output Console.ReadKey()?
SteveL-MSFT commentedon Oct 3, 2019
This seems most likely an issue in .NET Core. Agree with Ilya (@iSazonov) that a simple C# console app to repro would be ideal.
AndrewSav commentedon Oct 3, 2019
I'm slightly preplexed by these comments. This is an issue that is stabely reproducible in powershell and it does not seem to be and obvious way to reporoduce it in a C# console app. Also it does not seem that there is any evidence is given that it is not a Powershell issue.
Could guys please clarify your line of thinking?
SteveL-MSFT commentedon Oct 3, 2019
Andrew Savinykh (@AndrewSav) when PSReadLine is not involved as shown in Keith Hill (@rkeithhill)'s example, pwsh has a simple ReadLine that doesn't do any translation of keys. It is whatever the .NET API returns.
AndrewSav commentedon Oct 3, 2019
Steve Lee (@SteveL-MSFT) thank you for this. Will I be too far off if I conjecture, that these services (Home, End, Ctr+Arrow ) are not provided by ReadLine itself, but by something else, for example on windows by console host?
AndrewSav commentedon Oct 4, 2019
I tested the issue with pwsh 6.2.3 on Windows and Ubuntu Linux 18.04. I also tested it with a simple ReadLine console program. Here are the results.
pwsh 6.2.3
.net core 3.0.100 program with Console.ReadLine
Console program text
In bash it works in any combination.
iSazonov commentedon Oct 4, 2019
PowerShell uses ReadConsole P/Invoke on Windows that is power method.
On Unix it emulates a line editor.
Possible fix for local host could be in
PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs
Line 1517 in 70a74fb
Perhaps Paul Higinbotham (@PaulHigin) could add more about ssh scenario.
I already opened API request in CoreFX repo https://github.com/dotnet/corefx/issues/36175 long ago.
49 remaining items
steven-willard commentedon Jun 23, 2021
This seems to be an issue still, I am unable to get ctrl+rightArrow or ctrl+LeftArrow to work in tokenizing the advance of the cursor location.
Here is a quick pwsh function you can dump in your console to confirm the readkey value.
LeftArrow and RightArrow returned just fine. (Along with the Control Modifier)
Here is my version info, are we sure this is closed, or did I miss something?
Name Value
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Linux 4.4.0-19041-Microsoft #488-Microsoft Mon Sep 01 13:43:00 PST 20…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
AndrewSav commentedon Jun 25, 2021
Steven Willard II (@steven-willard) yep, it's still broken. If you read the issue history, it seems pretty impossible to get stuff fixed here, and this is not just this issue, it's general attitude towards the community, e.g read this or this. I personally abandoned any hope of this being fixed and moved on.
npodbielski commentedon Jun 25, 2021
Andrew Savinykh (@AndrewSav) Steven Willard II (@steven-willard)
Yep. I've been watching this thread for 2 years, lately mainly for fun and kicks. There should be banner:
PS on Linux is just broken and looks line maintainers want it to work this way. It would be nice to have the same CLI for both OSes but it looks line it won't be PS.
I think it would be easier to use bash via CygWin or something similar than PS on Linux.
They should be just honest and kill it instead of lie to people that is 'cross-platform'.
pencoe commentedon Jun 25, 2021
Andrew Savinykh (@AndrewSav) Steven Willard II (@steven-willard) npodbielski
Yes, it's a pity... In this case (as far as i can tell) Powershell team and .NET team are playing "pass the buck" on each other.
Which is very sad, because PS is more powerful than bash in many ways.
No need to use CygWin since WSL and WSL2. In fact i found myself using bash on Windows more and more, because using PS on Linux isn't that easy as promised...
Peter
yodasad commentedon Jan 24, 2022
There are too many comments in this thread... I cannot figure it out, why was the issue closed?
Home, Ctrl + Arrow are still not working in pwsh on linux.
yodasad commentedon Jan 24, 2022
I've found a workaround: for Home and End you can use Ctrl+A and Ctrl+E respectively.
artisticcheese commentedon Jan 24, 2022
https://twitter.com/artisticcheese/status/1485698470791028741 leave comments under tweet to tell Microsoft that we still care.
hepptho commentedon Feb 4, 2022
On Ubuntu, with PowerShell 7.2, I got the expected behavior by adding the following to my profile.ps1:
This requires the PSReadLine module to be installed, but I think it always should be by default. You can use Get-Module to check if you are unsure.
To find the profile.ps1 file, you can use the $PROFILE variable or check the docs here.
See also the docs on Set-PSReadLineKeyHandler and PSConsoleReadLine. The customization options seem extensive; it's pretty neat.
That PSReadLine doesn't offer this behavior by default appears to be intentional, see PowerShell/PSReadLine#668.
Instead (as yodasad noted) there are Ctrl+a and Ctrl+e for beginning / end of line, as well as alt-b and alt-f for backward word / forward word. Those are Emacs conventions, apparently, but that's where I'm out of my depth.
artisticcheese commentedon Feb 4, 2022
This did not work for me from command line, I'm on 7.2.1 and Ubuntu 20.04.3 LTS (Focal Fossa) and I just executed those from command line instead of $PROFILE to test
hepptho commentedon Feb 4, 2022
Hmm, I'm on 7.2.1 / 20.04 too, and it works directly on command line as well as in profile.ps1.
An alternative that works for me as well is:
The default EditMode on Linux appears to be Emacs, see also here for a (presumably) comprehensive list of things that should work in different edit modes. It's a nice reference.
If that also doesn't work, then the only idea I have left - and that's a wild guess - is that the keys are hijacked by something else. That sometimes happens to me with shortcuts on Linux, but it would be weird with Home and End.
You could try (if you haven't already) [Console]::ReadKey() followed by Home / End, and see what happens, and if it tells you anything.
artisticcheese commentedon Feb 4, 2022
Issue was seen only when using Remote Desktop Manager, not present at Windows command line, otherwise solution by Thomas Hepp (@hepptho) works as expected
rkeithhill commentedon Feb 5, 2022
Thomas Hepp (@hepptho) RE
Set-PSReadLineOption -EditMode Windows- thanks for that!!! I can't believe what a dope I've been. I've been fighting the PSRL key bindings on Linux/macOS for a while now. But my main machine is Windows. For some reason, it never occurred to me to check/change the PSRL edit mode. 🤦♂️yodasad commentedon Feb 11, 2022
That was already done at the beginning of this thread on Sep, 2, 2019:
#8869 (comment)
It seems like pressing the Home button results in Escape following "H" and pressing the End button results in Escape following F, so I tried to do this:
And it works, Home and End buttons started to work as expected, but unfortunately after that I cannot type capital "H" and "F" pressing Shift+H and Shift+F, they started to act as if I press Home and End buttons moving the cursor to the Beginning and the End of line.
DTW-DanWard commentedon Apr 1, 2022
None of the above worked for me on Mac (PS 7.2.2) but this did - hope it helps someone else.
Create a new Terminal profile (or copy an existing) and add a Keyboard mapping for Home and End:
Home
Key: Home
Modifier: None
Send text: (using Mac keyboard, not external): CTRL+A
This should produce Send text of \001
End:
Key: End
Modifier: None
Send text: (again on Mac keyboard, assuming no other modifier key changes): CTRL+E
This should produce Send text of \005
Clifra-Jones commentedon May 13, 2022
OMG! Thank you. This has been driving me nuts for months!