Skip to content
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

Arrow keys don't work in Ubuntu Bash on Windows #10163

Closed
u84six opened this issue Aug 5, 2016 · 27 comments
Closed

Arrow keys don't work in Ubuntu Bash on Windows #10163

u84six opened this issue Aug 5, 2016 · 27 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug terminal Integrated terminal issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) verified Verification succeeded windows VS Code on Windows issues
Milestone

Comments

@u84six
Copy link

u84six commented Aug 5, 2016

  • VSCode Version: 1.3.1
  • OS Version: Windows 10

Steps to Reproduce:

  1. Bind bash.exe path to integrated shell ("terminal.integrated.shell.windows": "C:\Windows\sysnative\bash.exe")
  2. Open terminal by Ctrl-Shift-~
  3. Type a command: echo hello world
  4. Use up arrow to find the command in history (doesn't work)

This works in the new stand-alone bash terminal. This also works on a mac. Just not vsc.

@phfsantos
Copy link

I am also having the same issue. It does not work on version 1.4 neither.
Arrows left and right also not working.

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug upstream Issue identified as 'upstream' component related (exists outside of VS Code) terminal Integrated terminal issues labels Aug 5, 2016
@Tyriar Tyriar added this to the Backlog milestone Aug 5, 2016
@Tyriar Tyriar added the windows VS Code on Windows issues label Aug 5, 2016
@vrabcak
Copy link

vrabcak commented Aug 6, 2016

It is related to microsoft/WSL#111

@Tyriar
Copy link
Member

Tyriar commented Aug 8, 2016

@vrabcak thanks a bunch for pointing this issue out!

@cybrown
Copy link

cybrown commented Sep 23, 2016

For those using bash for windows in vscode and cannot wait to use the history, here are some usefull commands involving the bang character when arrow keys are not available: http://ss64.com/bash/bang.html

@u84six
Copy link
Author

u84six commented Oct 9, 2016

I can't believe that this one is still not working. I submitted this back and August. How long does it take to support a simple history buffer? The native shell (Win10 bash) works, why not vsc?

@Tyriar
Copy link
Member

Tyriar commented Oct 9, 2016

@u84six as mentioned above, this is an upstream issue microsoft/WSL#111

@longtomjr
Copy link

just want to chime in ;). The Developer of ConEmu, @Maximus5, has come up with a workaround for this issue. It might be worth it to look at what he did. :)

@Tyriar
Copy link
Member

Tyriar commented Oct 14, 2016

Not 100% sure but the fix may just be to have xterm.js set application mode?

@longtomjr
Copy link

longtomjr commented Oct 14, 2016

More info here: Build 6041

Edit: I cannot add the arguments to the "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe", and there is no array option to add variables (like Linux and OSX). [An option for variables on windows might be a useful feature in the future.]

@pre63
Copy link

pre63 commented Oct 16, 2016

#7266 (comment)

{
  "terminal.integrated.shell.linux": "bash",
  "terminal.integrated.shellArgs.linux": [ "-l" ]
}

@Tyriar
Copy link
Member

Tyriar commented Oct 17, 2016

-cur_console:p1 was not recognized as an option when I tried it. Also regarding windows shell args, this is working find in the Insiders's build.

@Tyriar Tyriar added the help wanted Issues identified as good community contribution opportunities label Oct 17, 2016
@Maximus5
Copy link

@Tyriar -cur_console:p1 is ConEmu switch!

@longtomjr
Copy link

@Tyriar sorry for misleading, I did not really know what the arg was for just grabbing around. @Maximus5 do you think it will be possible for us to recreate what you did to work around this issue using the method you used, also if you have any other info that you think might help the efforts please share. :).

From what I understood you have two workarounds, the initial one and the later one. I am finding it hard to see what you did for the later one, if it is possible can you please point to a commit or something ;). Thanks for the great work on ConEmu btw, it is a dream to use!

@Maximus5
Copy link

ConEmu provides the one workaround: automatic translation of native keypresses into Xterm compatible keypresses. In later (current) ConEmu versions this translation is turned on automatically when flag 0x200 is turned on for input console handle.

Actually, this is due to a bug (AFAIK the internal MS bug is filled for conhost).

Unfortunately, arrow keypresses may be encoded in two ways, and without wslbridge it's absolutely impossible to handle them automatically.

@Tyriar
Copy link
Member

Tyriar commented Oct 17, 2016

@Maximus5 thanks for the clarification 😃

@stereokai
Copy link

stereokai commented Dec 13, 2016

@Tyriar @longtomjr and update on this? Anything I can do to help?

@Maximus5 where can I learn more about this native to Xterm translation process? Thanks

@Tyriar Tyriar removed the help wanted Issues identified as good community contribution opportunities label Dec 13, 2016
@Tyriar
Copy link
Member

Tyriar commented Dec 13, 2016

I'm in the process of an uplevel to winpty@0.4.0 which should fix the issue, see https://github.com/Tyriar/pty.js/issues/10

@Tyriar Tyriar modified the milestones: January 2017, Backlog Dec 13, 2016
@wclr
Copy link

wclr commented Dec 15, 2016

The same problem here when working with docker container's bash session: docker-compose exec container-name bash

@CherryDT
Copy link

There is a simple workaround for using the history: Use the bash commands which use the Ctrl key! Yes, bash has those, but most people forgot their existence, it seems.

Ctrl+P: Previous command (like up arrow)
Ctrl+N: Next command (like down arrow)
Ctrl+B: One character backwards (like left arrow)
Ctrl+F: One character forwards (like right arrow)
Ctrl+A: Start of line (like home key)
Ctrl+E: End of line (like end key)
Ctrl+D: Delete character (like delete key)

For details, see http://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html#Bindable-Readline-Commands

There is just one small issue: Ctrl+P (arguably one of the most important commands) is usually executed by VSCode to show "Quick Open". There are three ways to solve this: You could reassign the "previous-history" command in bash, reassign the "workbench.action.quickOpen" command in VSCode, or - arguably the easiest solution - change your "terminal.integrated.commandsToSkipShell" setting in VSCode to exclude "workbench.action.quickOpen" (you would then have to move focus away from the terminal to have VSCode respond to Ctrl+P).

@horihiro
Copy link

I tried wslbridge to use arrow keys on terminal, and I successed.

  1. Download and execute wslbridge installer
  2. Add following code to User Settings of Visual Studio Code.
{
  "terminal.integrated.shell.windows": "C:\\Users\\%USERNAME%\\AppData\\Local\\wsltty\\bin\\wslbridge.exe"
}

NOTICE: you can NOT use an environment variable (i.e. %USERNAME%) in User Settings, you have to replace to your username.

@Tyriar
Copy link
Member

Tyriar commented Jan 3, 2017

@horihiro good to know you got this working that way as a temporary work around 👍

@u84six
Copy link
Author

u84six commented Jan 20, 2017

Does closing this mean that it's fixed? What do I have to update to fix this problem because it's still not working.

@Tyriar
Copy link
Member

Tyriar commented Jan 20, 2017

@u84six it's fixed in the Insiders build which you can test here, it should included in v1.9.0 in ~2 weeks time.

@ghost
Copy link

ghost commented Jan 20, 2017

Fantastic news, your efforts here are greatly appreciated!

I've been using Ubuntu in a Windows shop, (and dealing with some pretty poor graphics drivers because of it) it'll be nice to remove that bit of friction when this lands by switching to Windows 10.

@khards
Copy link

khards commented Feb 27, 2017

Good to hear that it's fixed in the insiders build. Perhaps I can encourage some Apple fanboys to develop on windows not we have all the Unix CLI tools built in.

@gengxuelei
Copy link

when type 'blank' or 'tab' ,there is a wrong blank space,use 'cat sth.txt',repeat this bug

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug terminal Integrated terminal issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) verified Verification succeeded windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests