This is issue 187 reformulated as a feature request. There are two problems with the current escape mechanism:
I would suggest using the same escape mechanism as ssh (newline tilde). It has the following good properties:
If you are wedded to preserving ctrl-^ . as the quit sequence, I would suggest at least making the behavior a little saner:
Making the escape key configurable may be considered.
I went ahead and implemented the OpenSSH escape sequence behavior (and factored out the character to a variable so it might be able to be set by a configuration option later) in the referenced commit. I believe I implemented the OpenSSH semantics faithfully, but I'd totally be willing to believe I screwed up. (No clue if it will be wanted or merged, obviously, but I personally liked the suggestion, and figured I'd hand it over ;P.)
You rock! I haven't tried it but it looks right. Things I noticed:
I'll try to take a closer look later.
1) It turns out that '\r' was actually /required/: it did not work when I tested it using '\n'. I did not copy the code, however, so I'm willing to believe it should be /only/ '\r', but only checking for '\n' is apparently not right. ;P
2) Damn. :( :(
I went ahead and looked at OpenSSH's code to verify that it should be checking for both '\n' and '\r', and in fact that is the correct behavior (you will also note that it calls the variable last_was_cr, as '\r' is apparently the more canonical form).
/*
* Normal character. Record whether it was a newline,
* and append it to the buffer.
*/
last_was_cr = (ch == '\r' || ch == '\n');
buffer_put_char(bin, ch);
bytes++;
Just an additional note on C-^, C-^ can't be typed on Spanish keyboard layouts, because it's a dead key to make 芒锚卯么没. We can type it with ^ + space, but of course that does not work with any ctrl key pressed.
Another option would be the telnet escape "^]".
FYI, in current mosh, C-^ ^ sends a literal C-^. This is documented in the manpage.
(This is analogous to screen, in which C-a a sends a literal C-a. The reason this is a good idea is so sending the escape character through a stack of n moshes or screens doesn鈥檛 take 2^n keystrokes.)
And it鈥檚 already the case that C-^ char sends a literal C-^ char, except for a fixed set of chars.
viric: in case it helps, C-~ and C-6 are equivalent to C-^.
ah right andersk, C-~ and C-6 work both. Thank you! Then, no concern from my side. But as a preference, I'd go for the openssh escape sequence too. Only because I'm used to it.
Also, I'd like to add that the message 'Press Ctrl-^ . to quit' is misleading. The ^ char is not in the same keyboard key for all keyboard layouts. I had to go to IRC and ask how to quit mosh because I was indeed pressing the key for ^ in my keyboard and it wasn't working; Take a look on how the ABNT keyboard layout (default in Brazil) places the ^ char: http://www.verinha.de/teste/lfc03_tec_abnt.jpg
@kurtkraut: We're looking for Ctrl-^, regardless of which keyboard key ^ is on. I believe the problem in your case (as determined on IRC) is that ^ is a dead key used for typing letters like 锚.
Another problem with Ctrl-^ is you can't type it when using rxvt-unicode and an US-layout. rxvt-unicode uses Ctrl+Shift1 for it's weird ISO 14755 text-entry mode (which can only be disabled at compile-time), so you can't type Ctrl+Shift+6
@The-Compiler: You can leave off the Shift. ^6 isn't a character, so rxvt-unicode interprets Ctrl+6 as ^^. We should probably document this better...
@viric I'm trying those with my ES layout but can get it to work, how do yo do it exactly?
Damn, now I can see how is it. Forget it. Thanks to @andersk :-)
Perhaps what we should do is pop up the overlay bar on Ctrl-^ (or 1 second after that), explaining what Ctrl-^ . and Ctrl-^ ^ do, to help out users who type Ctrl-^ expecting it to do something to the inner application.
Just wanted to come by to tell that I've using the past two hours almost trying to figure why I couldn't get this to work on my Mountain Lion system :P
Using both iTerm2 and Terminal.app, and a norwegian keyboard, I ended up re-setting iTerm2, and figure out that I need to press only CTRL+6 . And not SHIFT, ^, etc.
One way I do believe helped somewhat, were the CTRL+V (Ref. https://en.wikipedia.org/wiki/Synchronous_idle) feature, to display the escape sequences in raw data. When I found ^^ I had the correct one.
So my conclusion would perhaps be that this combo is a bit hard to get right for everyone without some trial and errors :)
Using Mountain Lion and iTerm using neither CTRL+6, CTRL+SHIFT+6 nor CTRL+1 works...
I don鈥檛 know why you think C-1 should work. Again, the equivalent sequences are C-^, C-~, and C-6. If none of these work (or even if only some of these work), you should probably report an iTerm bug or an iTerm2 bug.
CTRL-~ ? Great, this is assigned to hiding/showing terminal for me..
Can't mosh use some sane shortcut (or make it configurable on client side)?
I also have a dead-key ^ (it needs shift+button+space to write it). CTRL+6 was a total helper. I have indeed used a lot of time on this. Actually saying "CTRL+6" in the wait dialog would help immensely. 6 and ^ is in totally different places on my keyboard, and although a literal C ^ might've worked, it doesn't because ^ is dead here.
Hello.. I have filed feature request, which is related for ^^ issue with mosh, for mintty. http://code.google.com/p/mintty/issues/detail?id=357 Short version: instead of ^6 for ^^ mintty users need to use ^^.
Please star mintty issue if C0 key combinations are too hard to use or to remember because they aren't compatible with other terminals.
Can someone merge this change if it's working well enough?
In Mac OS, Ctrl+^ is the default key combo for going to virtual desktop 6. The way SSH quits with "Newline+." is something everyone is familiar with and should be the most familiar among almost all of Mosh's users.
Any progress on getting this merged in, or a plan on how to address the funkiness surround ctrl-^?
This is a pretty handy key inside of vim, which I've had to remap to avoid mosh's use of it. Would be great to move to the OpenSSH standard escape sequence.
I think, honestly, my thinking on this has changed and I would be open to moving to RET ~ . in a future major Mosh version. If somebody wants to prepare a pull request, it would be favorably received.
Hi all,
I have 2 temrinal locked and telling me i can exit by using ctrl - ^ . I'm not sure what i'm supposed to do, but pressing the control key and the "^" key at the same sure doesn't work.
@keithw I see you made this configurable, however I've been unable to find anyway to configure it - the man pages for instance say nothing. All google search on the subject bring me to that bug report so that's not helpful.
It's in the man page for mosh : https://github.com/mobile-shell/mosh/blob/master/man/mosh.1#L289-L294
mosh.1. Try Ctrl-6, though, that may work. It's hard to change this default now because it's so important, though.Ctrl-^ then ., are you aware of that? When viewed in our documentation, that . unfortunately can be misinterpreted as normal end-of-sentence punctuation or a typo.Got it foreign keyboard, ^ is a dead key and it looks like it isn't working.
@cgull Ctrl-6 + . works for me, but Ctrl-^ + . doesn't.
My keyboard layout is: http://s2.glbimg.com/hlQMZ_E87B3DB_96rVuO_pY2Yy8=/695x0/s.glbimg.com/po/tt2/f/original/2016/06/21/900px-kb_portuguese_brazilsvg_.png
I'm using US-International and Ctrl-6 results in a "boop" from macOS. Not sure why.
As a German on German keyboard I had no clue how to read it and what to press. CTRL (STRG) + 6 + . however worked after reading it here.
Considering that mosh reminded me to install some language pack on the server I was moshing into there could be a better clue for international users. On German keyboard the ^ sign is actually typed by with they key left of 1.
Where is it on US Keyboard? I first thought it meant pressing shift.
I am a German using the US-int keyboard layout.
No combination of CTRL+(shift)6 and . has done anything for me.
I am usually not an idiot, but I can't quit mosh sessions.
I have to kill the mosh client from a separate shell.
If I can't do it - loads of people can't do it. I go as far as to say the current default behavior is stupid far from ideal.
Dutch using the US-int keyboard layout.
CTRL - (shift) 6 and a . doesnt work, have to wait until a time-out.
Should I press CTRL, the - and and shift and 6 at the same time?
Would it be possible to configure another key-combination? let's say CTRL SHIFT and Q ?
@keithw Can you reopen this issue or should we create a new one?
Hi @kwinz -- can you clarify why you'd like to see his issue re-opened? We recognize that the default escape sequence is not ideal on all keyboards/locales, but you've long been able to change the escape code (this is documented in the mosh man page -- see the section titled "Escape Sequences").
Do you want us to change the default? Or are you unable to change the escape sequence for some reason?
I'm a little bit appalled that there are so many recommendations for shortcuts, that only work remotely well on US keyboards. Most common PC shortcuts, especially the legacy ones from the old days before the year 2000, are extremely atrocious to type on non-US keyboards. I had problems with the Mosh shortcut for quite a while until I got a professional keyboard that was only available with a US layout, which makes things easier, regarding shortcuts on the computer.
So, can we not update the shortcut world a bit to the new reality? I had the same issue as @kwinz back when I wasn't using a keyboard with a US layout and even now, when I can use CTRL+6, it still kind of feels weird, because the system still expects CTRL+^.
That said, @eminence I did not know you could change the default. Still, there is no point in keeping an atrocious default and just pointing people to _oh you can just change it_. Especially, since it is best if software works as well as possible out of the box, without you being forced to change some really bad default option.
Therefore, I think it is just reasonable to change the default to something human and not keeping it as something weird. Especially, since ^ has already a special meaning for CLI users! Additionally weird and confusing!
Let's just change the default to something that actually makes sense...
To be clear, the system does not expect Ctrl+^ or Ctrl+6, it expects the byte \x1E, and it actually has no idea which keys you pressed to generate that byte鈥攖hat information is not made available to programs running in a terminal. There鈥檚 no reason to consider that weird. Every ASCII control byte can be generated via multiple key combinations:
\x00: Ctrl+@ or Ctrl+` or Ctrl+2 or Ctrl+Space,\x01 through \x1A: Ctrl+A through Ctrl+Z or Ctrl+a through Ctrl+z,\x08 (Ctrl+H) is also Ctrl+Backspace,\x09 (Ctrl+I) is also Tab,\x0d (Ctrl+M) is also Enter,\x1B: Ctrl+[ or Ctrl+{ or Ctrl+3 or Esc,\x1C: Ctrl+\ or Ctrl+| or Ctrl+4,\x1D: Ctrl+] or Ctrl+} or Ctrl+5,\x1E: Ctrl+^ or Ctrl+~ or Ctrl+6,\x1F: Ctrl+_ or Ctrl+/ or Ctrl+7.\x7F: Ctrl+? or Backspace or Ctrl+8.And of course, defaulting to any of these would likely have make someone mad because it鈥檚 in use by their favorite program. (Especially if their favorite program is Emacs, which uses every one of these bytes except \x1E.) There are only so many bytes!
I鈥檝e just gone and tested a variety of keyboard layouts (Arabic, Belgian, Chinese, English (international, UK, US), German, Japanese, Russian, Spanish), and Ctrl+6 successfully generates \x1E on all of them, irrespective of where the ^ is actually located.
This may of course depend on your OS and your terminal emulator. If your terminal emulator is missing some of these combinations, perhaps you should file a bug there?
@andersk
It is weird to build in bytes into UX design. That is utter non-sense.
The user does not care which byte the program uses to differentiate whatever. The user wants to use the program and not create their own philosophy on what bytes the program will understand.
However, if CTRL+6 is correct on all these layouts, then it should be at least pointed out in the message on the top, when mosh disconnected. Nothing with ^.
No -- the name (one name) of that character is Ctrl-^ (this is in the same nomenclature where "Ctrl-A" means 1, "Ctrl-B" means 2, etc.). See http://www.physics.udel.edu/~watson/scen103/ascii.html for the full table, including Ctrl-^. It wouldn't be correct to say Ctrl-6. But how you type it is up to you and your keyboard layout. The default escape sequence is not going to be convenient for everybody, which is why we added the environment variable to change it. We did this in version 1.2.5, released in 2015.
@keithw
That's what happens when a hardcore backender tries to reason up user facing design.
To the user it does not matter if it is "_correct_". It has to work. Nobody cares, if it is technically the correct sign, the user just wants to know what he is supposed to do. He does not want to know how the program's code is written, just because he is using it.
Proceeding with this reasoning, it does not make sense to display ASCII characters in a text document, as in the end, it is saved as bits on the disk. So displaying these characters is "not correct".
As already said, even if the default is variable, it does not change the bad situation of the current default. That does not make the default better.
So _even if_ the default does not change, the message should at least show something that makes sense. (No -- showing what the code thinks, is not something that makes sense to the user, see segfaults as a very rough example...)
@theAkito The truth is that there are multiple principles at play here.
One valuable principle is the idea of making things as easy as possible for users who, as you say, don't really care to master the tools (or read the man page or FAQ) but just want software to work without bumping into anything unpleasant.
Another valuable principle is the idea of modularity and trying to behave predictably so that users can compose Mosh and expect it to behave predictably. Mosh is a somewhat normal "command-line" program that tries to play well in the ecosystem; it does not "own" your keyboard input (it doesn't know what layout you are using or how you generate the bytestream it sees; it just accepts the bytes you give it), and it doesn't "own" your display (it doesn't pop up a window on your screen). We don't want Mosh to know these things or try to take over more of the ecosystem. Mosh interfaces with other programs using international standards (in this case, ASCII and ECMA-48), and we use standard nomenclature (e.g. "Ctrl-^", with a lot of handholding for how to type that and how to change it) for what we expect from the user.
So: we have an FAQ entry about how to type this, we have text in the manual page about how to type this, and we have guidance on how to change it if it is inconvenient for you... We're trying to meet you at least halfway here! :-) But if you think this needs to be immediately accessible without doing anything unpleasant on your end (including reading the FAQ, or reading the manual, or setting an environment variable, or complaining to your keyboard layout author that they make this particular ASCII character hard to type, or suggesting a particular alternate default that you want us to switch to after all these years), I'm afraid Mosh is not trying to win your business and may not be willing to make the kinds of compromises necessary to get there.
@keithw
In case I was misunderstood: you are right all along. I don't want to say that you are incorrect. Never meant to say that. All I am trying to say, is that the user has to understand what to do so the program behaves the way they want to.
The problem with the FAQ etc. you mention is that the user has to look up something if they just want to use the program. But if they want to engage further in it and do something more advanced, which would maybe require some advanced knowledge to begin with, anyway, they don't have to look up this little thing?
So all I am trying to say: just show CTRL+6 in the banner. Then, if someone is interested or needs predictability, any of the advantages of truth that you mentioned or anything advanced for advanced users only, THEN they can look it up and then the FAQ should say "_We show CTRL+6 for easier usage, but it is actualy byte XX_.". I would find this much more reasonable from a UX perspective.
Especially, since your last post shows, that you are very knowledgeable on this topic. Which is great. So maybe for you the
standard nomenclature
is pretty standard and pretty self explanatory. But I assure you, for most normal users, that is something they never heard of.
So my opinion is, that it is better to display something that nerds, experts, beginners and other people understand instead of something only nerds and experts understand, where the only consequence would be that some nerds would complain about it not being technically entirely correct (since, in this scenario, they could look it up in the FAQ anyway, if they wanted to know about it precisely).
P.S.:
To sink in the final nail into my statement's door to understanding:
Due to me having to work with the CLI daily these symbols weren't new to me. However, since I used a non-US keyboard for the most part of my life, I never bothered with handling any advanced combos, as there was no point to it on that particular keyboard, where it is particularly hard to type certain symbols.
In the following particular case, I did not know that CTRL+6 equaled the same byte as was requested by mosh.
So here is what happened:
mosh point broken. I could use plain ssh if I repeat this procedure.This happened a lot of times, but I could never fiddle around with that key to _actually_ press, so I can reconnect or close the connection for good or whatever, because I needed to continue to work on the server.
I imagine that happened to a lot of people, especially with a non-US keyboard layout. All this could've been avoided entirely with a banner telling me _"Hey buddy! Just press CTRL+6!"_.
However, if I was interested in the actual byte, I could've visited the website when I'm free to do so, to read the FAQ regarding this byte. That way, everyone should be happy, in my opinion.
P.P.S.:
Again, you are _technically_ correct. I am talking from a design perspective, not from a technical perspective, since we have already a lot of very high skilled technical people here.
Here, have another vote on this eight-year-old issue, for adding something like "(alternatively, Ctrl+6 .)" to the banner message. It'd be a really simple, user-friendly and side-effect-free solution to a significant usability hassle.
I'm using mosh only on one server with a particularly flaky connection, and every time I run into problems there (which is about once every 6 months so I've almost forgotten I'm even using mosh) I keep coming back through google to this issue in order to look up what the alternative key combo was.
(And I've been fiddling around enough with ancient serial terminals recently that I am indeed aware of the relationship between Ctrl and the lowest 32 ASCII byte values...)
I am used to ^ being the meta character for control, so I didn't understand the message Ctrl-^ ., it seemed to be redundantly saying to press ctrl, and then .. And "what is the ^" is pretty close to ungooglable. I immediately ruled out that it was a literal ^, since that is not a normal way to escape a program, and it usually indicates a meta character.
... Anything would be better IMO.
Most helpful comment
viric: in case it helps, C-~ and C-6 are equivalent to C-^.