riscy / shx-for-emacs

An Emacs shell-mode (and comint-mode) extension that enables displaying small plots and graphics and lets users write shell commands in Emacs Lisp.
GNU General Public License v3.0
218 stars 10 forks source link

ipython in shx with tramp #14

Closed inglada closed 4 years ago

inglada commented 4 years ago

Hi, I am not sure I am using shx in a proper way, but my use case is the following: I edit files on a remote machine using tramp. Once there, if I run shx, I get a shell on the remote machine, which is great.

However, sometimes I want to run ipython on this remote machine, but if I run it from shx, I don't get the proper ipython prompt and I get this message:

WARNING: your terminal doesn't support cursor position requests (CPR).

Is there a way to configure shx so that the ipyton shell works OK?

Thanks.

riscy commented 4 years ago

I can recreate the issue even on my local machine:

$ ipython
Python 3.7.1 (default, Dec 14 2018, 13:28:58) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

WARNING: your terminal doesn't support cursor position requests (CPR).

I have no prompt in this case, but I can run commands and get output:

10 + 32
Out[7]: 42

The reason this is happening is because shell-mode (which shx sits on top of) is an extension of comint-mode, which only supports what are called "dumb" terminals (which can't be told to move the cursor around, for example, and prefer raw input/output).

The fix that works for me is to use ipython --simple-prompt (ipython has lots of other options that you can see using ipython --help). If that works, you could create an ipython profile on the remote machine (see here) or set up an alias.

inglada commented 4 years ago

Great! The --simple-prompt option is perfect for what I need. Thank you.