-
Notifications
You must be signed in to change notification settings - Fork 25
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
Editing through ssh session is broken #12
Comments
Please try MSYS2's nano. Keyboard inputs are handled by the native (i.e. not basing on any form of POSIX simulation) ncurses which does not conform to POSIX. |
Just tried to start the ssh session whithin MSYS2 environment and i've got the same results as above. This issue seems to be linked to the target machine's nano (which runs Windows with nano too): the ssh session brokes something somehow during it becouse with local files everything works good. Can you reproduce the problem? |
nano-win is not meant to be functional over SSH (note this is ncurses' limitation not nano's). You should use MSYS2's nano which can be installed via |
@graphixillusion you might be interested in this: https://github.com/billziss-gh/sshfs-win/ Mount your |
Thank you to everyone for the support. I think i've found another workaround: use the MSYS2 nano as @lhmouse suggested, then create a shim to nano.exe and put the created shim files inside a dir which is in an environment variable, so when i ssh remote that machine and type "nano whatever" it works using the MSYS2's nano. Now there is only one problem left: type the special characters of my keyboard, like àèìòù and so on (IT keyboard). |
The reason why it doesn't over SSH is a bit complex but I'll try to elaborate a little: A POSIX terminal (such as the ones you get on a Linux machine by pressing F1 to F6 which are virtual terminals, or the ones created by SSH sessions or GNU screen which are pseudo terminals) is basically a bidirectional character stream. You can move the cursor around, scroll an area, set text colors, etc. by sending control characters to it. A Windows console works differently. You may read characters from or write to it. But if you wish to move the cursor, to set text colors etc. you have to call specific system API functions with the console handle. The Windows approach might sound more efficient. However, the most notable advantage of POSIX terminals is that as long as control characters can be delivered you really don't have to care about how they are delivered. That's why pseudo terminals are functional via SSH (and also note SSH tunneling, like Matryoshka Dolls). On Windows this would require some program to translate control character sequences into native Windows APIs, which is what MSYS2 does. |
@lhmouse thank you for the explanation. I've one question about it: why vim editor works good instead? What's the difference? |
Are you referencing the MSYS2 vim? |
Nope, i use the official windows vim binary from the official website. |
I came here for this exact same reason. I install Nano using choco (which is way outdated) and when using SSH into Win10 machine it doesn't work (as stated above), but vim installed by Also @lhmouse why isn't there an windows installer for this?
|
@graphixillusion When I SSH into a Win10 machine with this nano.exe, I am able to navigate correctly using the arrow keys, however, while the cursor placement is wrong, the typed text appears in the correct place! # SSH into pwsh.exe shell using:
ssh -2 -t username@xx.xx.xx.xx "pwsh -i"
# Set the remote TERM to be "cygwin" instead of (default) "xterm":
$Env:TERM = "cygwin" # not needed
nano -cg .\test.txt Hitting So if this could be automatically executed after each character received, we would have a working Nano, also in SSH, AFAICT. |
Syntax files are loaded as specified in your primary As for the Again: I know no curses details. I only ensure that nano builds as a native program, Ctrl, Alt, FN keys etc. work in native consoles. There's a lot of issues, such as UTF-8 not working, glitches, etc. If you work through SSH (Cygwin I presume) then I highly recommend the Cygwin or MSYS2 nano. You may build one yourself if it's out of date. |
Yes, I know. But on Windows where is the location of |
The above isn't proper, my bad. This is :
|
I still think the |
Any updates? |
@E3V3A The issue above works on Linux because the process receives |
Hi @lhmouse
Not sure what you mean. I was not using Linux when testing, the issue (as it was described and occurred for me), was on connecting windows to windows.)
|
You cannot include Windows consoles work differently from Linux. On Windows you have to call So, back to your original question, why there is Ctrl-L? On Linux you can put a program to background with Ctrl-Z, while it may still write to your console. Other programs can also write to your console if they have root access. This means that when you are editing a file, other programs may mess up with your screen. When this happens, you can force a redraw with Ctrl-L. Of course, on Windows this can hardly happen. |
@lhmouse |
The MSYS2 or Cygwin nano might work better with SSH. However they do have shortages (if not bugs). For example, recently nano has gained a feature that you can backspace a word by pressing Alt-Backspace, which does not work in MSYS2 nano, not even in Mintty. Maybe it's too old; I don't remember when nano added this feature. |
Indeed, I wish I had read this thread before! As my other reported issues with this nano build, was driving me crazy, as everything seem to work, except syntax highlight. So I tried running the Cygwin (MSYS2) version of nano.exe, in both the The results is that version works (with all the .nanorc files and paths from win version). # file /usr/bin/nano.exe
PE32+ executable (console) x86-64, for MS Windows
# THIS version!
# file /cygdrive/c/mybin/wintools/nano/bin/nano.exe
PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows
# /usr/bin/nano.exe -V
GNU nano, version 4.9
(C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
(C) 2014-2020 the contributors to nano
Email: [email protected] Web: https://nano-editor.org/
Compiled options: --enable-utf8
# /cygdrive/c/mybin/wintools/nano/bin/nano.exe -V
GNU nano from git, v5.9-10-gbe0fb5d4a
(C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
(C) 2014-2021 the contributors to nano
Compiled options: --disable-libmagic --disable-speller --disable-nls --disable-utf8 @lhmouse What is the issue with UTF-8? AFAIK, the entire windows-10 system has been built to automatically support UTF-8, but that there may be issues when trying to use UTF-8 files with and without BOM. To check your current Windows locale etc, use something like: [console]::InputEncoding && [console]::OutputEncoding && $OutputEncoding && chcp |
The issue about UTF-8 is that the MSYS2 or Cygwin nano supports UTF-8 via the MSYS2 or Cygwin C runtime. But nano-win works on MSVCRT which does not support UTF-8. Legacy MSVCRT is actually a double-byte-character-string system which means a multibyte character (UTF point) can take at most 2 bytes, while in UTF-8 it's up to 4. |
So what is the reason you're not using UCRT? |
Oh boy... |
The only reason is that this project predates the MSYS2 UCRT subsystem, and nobody has requested UCRT builds so far. If you request it, I can build it for you. Please be on topic after all. |
What ssh server are you using? These builds actually work perfectly over recent versions of openssh for windows, the only issue I had was with the config file location when the shell is elevated, as it is in an ssh session (#34). You can install openssh for windows with choco like this (run this in powershell): choco install -y powershell-core sed
stop-service ssh-agent
sc.exe delete ssh-agent
choco install -y openssh --prerelease --force --params '/SSHServerFeature /SSHAgentFeature /PathSpecsToProbeForShellEXEString:$env:programfiles\PowerShell\*\pwsh.exe'
refreshenv
sed -i 's/^[^#].*administrators.*/#&/g' /programdata/ssh/sshd_config
restart-service sshd
&(resolve-path /prog*s/openssh*/fixuserfilepermissions.ps1)
import-module -force (resolve-path /prog*s/openssh*/opensshutils.psd1)
repair-authorizedkeypermission -file ~/.ssh/authorized_keys |
I already got this issue with the previous version (4.6) that's why i asked in the other thread for new build but the issue i'm going to describe still persist: editing with nano through ssh session is completely broken. I mean, arrow keys doesn't work, enter key doesn't work, space doesn't work; Ctrl+x seems to work but strange chars will be printed out upon exit in the shell (�[?2004h�[?2004l). No problem with editing with local files in the Windows cmd shell. I forgot to mention that i've tried with putty and the official windows ssh client: same results in both scenarios.
The text was updated successfully, but these errors were encountered: