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.
Use OpenSSH escape sequences, suggested by @pimlott in #215.
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.
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
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');
As reported by @pimlott in #215: remove literal ~.
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’t take 2^n keystrokes.)
And it’s 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’t 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.
RET ~ .
mosh-client: Make terminal escape character configurable
Uses environment variable MOSH_ESCAPE_KEY. Defaults to current Ctrl-^
which is somewhat problematic for many non-US keyboards.
Signed-off-by: Timo J. Rinne <email@example.com>
Closes #425. Closes #215.
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
Got it foreign keyboard, ^ is a dead key and it looks like it isn't working.