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
Arrows ignored by bash when it started in ConEmu #111
I'm the author of ConEmu - alternative terminal for Windows. My users have created the issue ConEmu/ConEmu#629. When bash is started in ConEmu console, it totally ignores all extended keys (Arrows, Fn, etc.), so users can't access command line history with Up/Down arrows.
What is the problem with bash? Up/Down arrows properly cycle cmd.exe history, when it's started in ConEmu, but bash ignores them.
ConEmu is GUI application, so it get keyboard events via WM_KEYUP/WM_KEYDOWN and forward them to the created (usually hidden) real console using WriteConsoleInput.
Reacted by Daniel Augusto, interpeix, Ophir Yoktan, Aran Whisper, Niklas Grebe, Arun Seetharam, Nikita Tokarchuk, Yuriy Voziy, Eric McCann, George Hahn and 135 more
Reacted by Diego Jara, Jason Blackwell, Alex, Roger Braunstein, Bryce Schober, Sid Shaytay, Andrei Mocanca, Jan Akhremchik and wudeyong
bash.exe has its own logic to read from console directly (this is as per the design today and subject to change in future releases). I am not a console expert, but I wonder if ConEmu interacting with the console directly is interfering with bash.exe's ability to process keyboard events?
ConEmu use official console API WriteConsoleInput to post keypressed into the conhost input buffer. That worked perfectly until "Bash on Ubuntu" appears.
Ok. I am not sure I fully understand the problem here. My understanding of this issue is that bash is not able to process arrow keys when launched from within ConEmu? Can you help clarify.
But Unix console applications expect different key sequences.
For UpArrow keypress either ESC [ A or ESC O A sequences are expected
depending on requested ‘DECCKM’ mode.
References: ANSI sequence ESC [ ? 1 h and ESC [ ? 1 l.
The bash.exeis Windows console application, therefore it's expected
that this application would work properly with standard Windows console API
keypresses (KEY_EVENT_RECORD, VK_UP). But, I'm not sure who, the translation
is done when user presses UpArrow. And bash.exe recieves ESC [ A instead.
Well, that is rude workaround, but if bash.exe is started in ConEmu with -cur_console:p1 switch, ConEmu does this translation and arrows magically
start working.
That is really rude, because ConEmu does not recieve ANSI sequences from
linux processes. And, when user starts vim from bash prompt, ‘DECCKM’ is not changed.
Therefore, ‘Arrows are not working in vim under ConEmu’.
There are absolutely no way to determine that vim was started from bash,
or vim has requested to change ‘DECCKM’ mode.
Seems like linux processes (init, bash, vim) somehow write their console output
directly to conhost, bypassing bash.exe. That's bad, because ConEmu has absolutely
no control over linux processes (started from service), only bash.exe may be hooked
to catch it's output and ‘fix’ input.
If you would like to check, download latest ConEmu build (alpha 160411 ATM),
and run from Win+R:
ConEmu.exe -basic -cmd bash.exe -cur_console:p1
Reacted by Daniel Kornev, Sathyajith Bhat, Ragnar Hägg, Asbjørn, sourcevault, Daniel Wozniak, Andrey Andrianov, Johnny, Bearice Ren, Matthew Simpson and 7 more
Sure, it is. Monday, 02 May 2016, 07:09PM +03:00 from Daniel Gordon < [email protected]> :
So Just to be clear here - you guys are talking about bash.exe - that is or is not the same thing as the new Ubuntu Subsystem in the most recent Windows 10 dev build?
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
Maksim Moisiuk (@Maximus5) I deleted my comment because I figured it out on my own by looking at the top of this page 10 seconds after I posted my comment... Sorry for the confusion.
Hi, console2 and consoleZ, two other terminal emulators, have the same problem with arrows not working on bash.
Reacted by Saad Farooq, Bryson Reynolds, Brunlof, Sid Shaytay, Jonathan Yee, Caleb Meyer, Søren Nguyen Boisen, Xiao Wenyang, sam0x17, Andrew and 1 more
Just would like to add that IMO this is quite important to have WSL working properly with ConEmu, because some serious console users (myself included) are not going to be satisfied with the basic Windows Console (which is now quite better than the legacy one, but still far away from any random XWindow Console we are used to)
For now I'm doing some dev under WSL on the Windows Console (for now coping with the international keyboard bugs it has by switching to a US layout) but I will be seriously disappointed if I can't use ConEmu for a vast majority of WSL software, and that obviously includes vim...
Reacted by Andrew Harper, Arkady Shapkin, Bron Thulke, David Mott, Kody, Davide Aversa, Graham Clark, Julien Roncaglia, Terence Tuhinanshu, Daniel Kornev and 36 more
Maksim Moisiuk (@Maximus5) I like conemu, all I'm saying is that the issue is bigger than just one program and it should be addressed with high priority.
Reacted by David Mott, Terence Tuhinanshu, John Louderback, Diego Jara, Conan, Matt Ragoza, Evgeniy, Saad Farooq, Mike MacCana, Sid Shaytay and 1 more
The Windows default terminals don't have nearly enough features for any power user
Reacted by lateau, David Mott, Alexis Ramis, Shang Li, Terence Tuhinanshu, Hoang Huynh, Carlos Alvarez, Ryan Ewen, Phoomparin Mano, Thomas Calmant and 7 more
Maksim Moisiuk (@Maximus5) thank you for ConEmu. It's a huge productivity improvement. MS should ditch the POS default console, give you a few million USD and ship it with every install of Windows.
Reacted by Daniel Kornev, Gunnar Velle, Hoang Huynh, Dan Wolf, Joel Van Eenwyk, Aubrey Falconer, Phoomparin Mano, Harald Glatt, u84six, Tim Scanlin and 8 more
Reacted by Andrew Harper, kcd83, Wiktor Kwapisiewicz, Terence Tuhinanshu, Hoang Huynh, Aamer Alduais, Phoomparin Mano, Harald Glatt, Viktor Oreshkin, z------------- and 2 more
Does this also affect recognition of Ctrl-C or Ctrl-Break? That is, when ENABLE_PROCESSED_INPUT is on, will WriteConsoleInput send a signal for these key presses? It currently doesn't, and I'm guessing that won't change. (If it did, I might be able to fix Ctrl-C handling is inadequate for interactive cmd and PowerShell rprichard/winpty#116.)
Is mouse input affected? There's an analogous situation where mouse input should produce VT escape sequences, and the encoding is controlled by mouse mode flags (e.g. 1006 for the "SGR mouse encoding"). I haven't gotten around to testing the console yet, so maybe WriteConsoleInput calls already do this conversion.
Do you have suggestions on how programs can detect this behavior change (i.e. so that a workaround can be disabled)? For my situation (winpty), I think it'd be worth it to temporarily enable the VT input mode and test whether input is converted (by calling WriteConsoleInput then ReadConsoleInput). I'm guessing there isn't a better approach, though I suppose checking the OS version could be faster.
That is great news (not so great that it won't make Fall.. oh well :-) ) .. just curious if this means that it ended up being significantly less work than initially expected? :-D
I don't believe it will. The change is pretty limited in scope to just the VT translator, so I don't believe any of the rest of the input is modified.
Mouse is unfortunately not fixed by this change. The keyboard events were easier to move than the mouse events unfortunately. I have a work item to address that issue before the end of the next release.
I don't have any good recommendations on that topic, sorry. Both the mechanisms you describe sound like they should work, though I have no idea which would be faster.
It was a bit easier than anticipated, but like I mentioned, mouse input is actually harder than anticipated unfortunately.
Sorry, guys, I know you're being bombarded, but can you tell us how being on the Windows Insider fast track might affect the speed at which we see some of these changes?
Brian G. Shacklett (@bgshacklett) If you're on the fast ring, you'll see these changes pretty immediately after they hit winmain, which is usually a month or so after I commit the code on my end. Otherwise, if you're on just a non-insider's build, you'll have to wait for the entire release to be finished, which is about twice a year (based on previous Windows 10 releases)
Reacted by Brian G. Shacklett, fpqc, Tira Odhner, Jordan W, i336, Aldo Fregoso and Trevor N. Suarez
Activity
Maximus5 commentedon Apr 12, 2016
I've created workaround in ConEmu build 160411. However, it would be nice to know, is it a bug or intended behavior.
Maximus5 commentedon Apr 13, 2016
Unfortunately, arrow keys still do not work in vim.
sunilmut commentedon Apr 13, 2016
bash.exe has its own logic to read from console directly (this is as per the design today and subject to change in future releases). I am not a console expert, but I wonder if ConEmu interacting with the console directly is interfering with bash.exe's ability to process keyboard events?
Maximus5 commentedon Apr 13, 2016
ConEmu use official console API WriteConsoleInput to post keypressed into the conhost input buffer. That worked perfectly until "Bash on Ubuntu" appears.
sunilmut commentedon Apr 13, 2016
Ok. I am not sure I fully understand the problem here. My understanding of this issue is that bash is not able to process arrow keys when launched from within ConEmu? Can you help clarify.
Maximus5 commentedon Apr 13, 2016
Short answer: Yes.
Many words below.
Let's take for example UpArrow key.
When user press and release UpArrow, normal console application
recieves two console key events:
References: PeekConsoleInput, ReadConsoleInput, INPUT_RECORD, KEY_EVENT_RECORD.
But Unix console applications expect different key sequences.
For UpArrow keypress either
ESC [ AorESC O Asequences are expecteddepending on requested ‘DECCKM’ mode.
References: ANSI sequence
ESC [ ? 1 handESC [ ? 1 l.The
bash.exeis Windows console application, therefore it's expectedthat this application would work properly with standard Windows console API
keypresses (KEY_EVENT_RECORD, VK_UP). But, I'm not sure who, the translation
is done when user presses UpArrow. And
bash.exerecievesESC [ Ainstead.Well, that is rude workaround, but if
bash.exeis started in ConEmu with-cur_console:p1switch, ConEmu does this translation and arrows magicallystart working.
That is really rude, because ConEmu does not recieve ANSI sequences from
linux processes. And, when user starts
vimfrom bash prompt, ‘DECCKM’ is not changed.Therefore, ‘Arrows are not working in vim under ConEmu’.
There are absolutely no way to determine that
vimwas started from bash,or vim has requested to change ‘DECCKM’ mode.
Seems like linux processes (init, bash, vim) somehow write their console output
directly to conhost, bypassing
bash.exe. That's bad, because ConEmu has absolutelyno control over linux processes (started from service), only
bash.exemay be hookedto catch it's output and ‘fix’ input.
If you would like to check, download latest ConEmu build (alpha 160411 ATM),
and run from
Win+R:Maximus5 commentedon May 2, 2016
Sure, it is. Monday, 02 May 2016, 07:09PM +03:00 from Daniel Gordon < [email protected]> :
DanielGGordon commentedon May 2, 2016
Maksim Moisiuk (@Maximus5) I deleted my comment because I figured it out on my own by looking at the top of this page 10 seconds after I posted my comment... Sorry for the confusion.
dariobig commentedon May 14, 2016
Hi, console2 and consoleZ, two other terminal emulators, have the same problem with arrows not working on bash.
Maximus5 commentedon May 14, 2016
@bigonazzi Of course they are. Only ConEmu is able to send xterm-ish keyboard sequences, which LX kernel expects.
xilun commentedon May 14, 2016
Just would like to add that IMO this is quite important to have WSL working properly with ConEmu, because some serious console users (myself included) are not going to be satisfied with the basic Windows Console (which is now quite better than the legacy one, but still far away from any random XWindow Console we are used to)
For now I'm doing some dev under WSL on the Windows Console (for now coping with the international keyboard bugs it has by switching to a US layout) but I will be seriously disappointed if I can't use ConEmu for a vast majority of WSL software, and that obviously includes vim...
Maksim Moisiuk (@Maximus5) thanks for your excellent ConEmu btw :)
dariobig commentedon May 14, 2016
Guillaume Knispel (@xilun) +1
Maksim Moisiuk (@Maximus5) I like conemu, all I'm saying is that the issue is bigger than just one program and it should be addressed with high priority.
Darktex commentedon May 14, 2016
Guillaume Knispel (@xilun) +1
The Windows default terminals don't have nearly enough features for any power user
djmott commentedon May 28, 2016
Maksim Moisiuk (@Maximus5) thank you for ConEmu. It's a huge productivity improvement. MS should ditch the POS default console, give you a few million USD and ship it with every install of Windows.
61 remaining items
jarun commentedon Sep 8, 2017
Good news. 👍 I just wasted an hour figuring out the issue and reached here.
rprichard commentedon Sep 8, 2017
Mike Griese (@zadjii-msft) Good to hear. A few questions:
Does this also affect recognition of Ctrl-C or Ctrl-Break? That is, when
ENABLE_PROCESSED_INPUTis on, willWriteConsoleInputsend a signal for these key presses? It currently doesn't, and I'm guessing that won't change. (If it did, I might be able to fix Ctrl-C handling is inadequate for interactive cmd and PowerShell rprichard/winpty#116.)Is mouse input affected? There's an analogous situation where mouse input should produce VT escape sequences, and the encoding is controlled by mouse mode flags (e.g. 1006 for the "SGR mouse encoding"). I haven't gotten around to testing the console yet, so maybe
WriteConsoleInputcalls already do this conversion.Do you have suggestions on how programs can detect this behavior change (i.e. so that a workaround can be disabled)? For my situation (winpty), I think it'd be worth it to temporarily enable the VT input mode and test whether input is converted (by calling
WriteConsoleInputthenReadConsoleInput). I'm guessing there isn't a better approach, though I suppose checking the OS version could be faster.ericblade commentedon Sep 11, 2017
That is great news (not so great that it won't make Fall.. oh well :-) ) .. just curious if this means that it ended up being significantly less work than initially expected? :-D
zadjii-msft commentedon Sep 11, 2017
Ryan Prichard (@rprichard)
It was a bit easier than anticipated, but like I mentioned, mouse input is actually harder than anticipated unfortunately.
bgshacklett commentedon Sep 11, 2017
Sorry, guys, I know you're being bombarded, but can you tell us how being on the Windows Insider fast track might affect the speed at which we see some of these changes?
zadjii-msft commentedon Sep 11, 2017
Brian G. Shacklett (@bgshacklett) If you're on the fast ring, you'll see these changes pretty immediately after they hit winmain, which is usually a month or so after I commit the code on my end. Otherwise, if you're on just a non-insider's build, you'll have to wait for the entire release to be finished, which is about twice a year (based on previous Windows 10 releases)
bitcrazed commentedon May 22, 2018
Thanks for the discussion.
Closing this issue since:
If you have further asks/issues, please file new issues on our Console GitHub Repo.
maietta commentedon Aug 27, 2023
I DO NOT CARE WHAT YOU PEOPLE KEEP SAYING. THIS ISSUE IS NOT FIXED IN WINDWOS 11 AND WSL2.
Why is this still an issue in 2023?
zadjii-msft commentedon Aug 28, 2023
Nick Maietta (@maietta) This issue was closed 5 years ago. The console codebase has had a tremendous amount of churn since then. Whatever you're seeing now probably has a new root cause. I'd recommend filing a new issue over at https://github.com/microsoft/terminal/issues, so we can ID whatever's causing what you're seeing.
Thanks!
nikhil-swamix commentedon Aug 23, 2024
for people running cli scripts in python: disable this
Terminal › Integrated: Windows Enable Conpty
key navigation will work, for packages like rich, fire, click cli tools...