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

Cursor keys not working in vi and strange artifacts when SSH to Linux machine from Windows Powershell #2443

Closed
2 tasks done
russellseymour opened this issue Nov 8, 2017 · 2 comments

Comments

@russellseymour
Copy link

russellseymour commented Nov 8, 2017

  • I am on the latest Hyper.app version
  • I have searched the issues of this repo and believe that this is not a duplicate

Issue

I am trying to use Hyper as a an alternative to Cmder/ConEmu as I think it has better support for tmux etc.

However I have come across something that is quite strange.

If I use Hyper and SSH into a Linux machine from Windows PowerShell (SSH is on the path) then cursor keys do not work in vim. Also the terminal is not setup correctly when vi is running, so you can see lines of the command line interspersed, making it impossible to know what is in the file.

hyper_2017-11-08_08-31-27

(I am unable to provide an Asciinema video for this as it does not run in PowerShell or Command Prompt)

The SSH I am using here is in my path and comes from Git for Windows.

I have also tested this using cmd.exe as the shell in Hyper and I get the same results as above.

However if I do the same thing from WSL, e.g. SSH into my Linux machine then everything works as expected. The cursor keys work and I can edit files using vi.

asciicast

I have checked the obvious things like the TERM environment variable and it is set to xterm-256color in both cases.

In this case the SSH comes from Ubuntu (which is what I have running in WSL) so the SSH binaries are different. There might be a option I can set in the SSH command in PowerShell that would make this work. I will dig around and post a comment about what I find.

I have found an issue that relates to this, #1968, where the messing with the file display in vim possible due to the TERM variable.

I use PowerShell as my default shell and I have SSH on my path so I can drop into machines as and when I need to. I am assuming there is something in the PowerShell environment that means things are not displayed properly when using SSH. However this is slightly strange as I am getting into WSL by typing bash in the same PowerShell session and it all works OK.

Happy to provide more details to help assist with this. Please let me know if required.

@russellseymour
Copy link
Author

I think that I have fixed the issue where vim does not display correctly. It I set the TERM in the SSH session on the Linux machine then vim displays the file correctly.

So do this permanently from PowerShell the TERM environment variable needs to be passed. This can be set in the session or in the profile.ps1 file. SSH will forward this value in the SSH session so on the Linux machine it is set correctly.

So do this in the PowerShell session run the following

C:\ > $env:TERM="xterm-color"
C:\ > ssh <TARGET_MACHINE>

The cursor keys in vim still do not work, so if anyone has any good ideas for that I will be very grateful. (I can use the h,j,k,l keys but that requires a habitat change :-))

@russellseymour
Copy link
Author

I will now close this issue as I have fixed all the problems.

I wondered if it might be down to the SSH binary I am using. So I installed OpenSSH for Windows using Chocolately (choco install openssh) and all the problems I had have gone away.

Hopefully this will help someone in a similar position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant