mobile-shell / mosh

Mobile Shell
https://mosh.org
GNU General Public License v3.0
12.63k stars 734 forks source link

Unable to paste code with indentation into mosh #1066

Open rjurney opened 5 years ago

rjurney commented 5 years ago

I get errors when I paste indented code from my Mac into mosh. The indentations add up each line and the text gets further out with each indented line. This makes my Python code not run.

Use case: I often use Spark clusters from the master node via ssh and want to use mosh to do the same without worrying about the connection dropping and losing my work. As far as connections staying up it is great, but I can't paste code from a file and watch it run, which kills me. I end up trying to remove indentation and do things all in one line, and finally give up and use ssh, which drops connections :( I've tried screen and tmux.

Is there a way to get this to work through mosh? It works seamlessly through ssh.

cgull commented 5 years ago

That's quite odd, Mosh mostly passes input through without altering it. (The one exception, the Control-^ character, is pretty unlikely in Python code.)

What application are you pasting into, on your remote Spark machines? Possibly this is something related to handling quoted pasting. If you're using an editor that auto-indents for Python for interactive use, that might explain the extra indent you're getting (auto-indent from the editor, and spaces from the text you're pasting).

rjurney commented 5 years ago

I’m pasting into the ipython based pyspark shell. Thing is this just works in ssh.

deed02392 commented 5 years ago

This is nothing to do with mosh. This is because your text editor has auto indent enabled.

andersk commented 5 years ago

@deed02392 As much as we’d like Mosh to always be blameless, we need to investigate before jumping to conclusions. The user did say that SSH works as they expect.

@rjurney Is it possible that you’re using an old version of Mosh? Bracketed paste support was added in Mosh 1.2.5; you’ll need at least this version on both the client and the server.

rjurney commented 5 years ago

@deed02392 @andersk yes, it would seem to involve mosh because ssh works fine. Or some setting or something.

I’m using 1.3.2 for all three machines I’m sshing between. One Mac and two Ubuntu 18.04 machines.

Is there some capture or log I can supply? Or can I give you instructions on how to reproduce? If you mosh and run ipython and then paste in a python function it should happen.

eminence commented 5 years ago

can you also tell us what terminal you're using on your macos machine? That might help someone try to reproduce this

rjurney commented 5 years ago

Oh, good call. Maybe this is specific to iTerm2, I’m on the latest. I’ll try other terminals.