1

I'm using gnome-terminal, emacs -nw, eshell inside emacs, and ipython.

For some reason the emacs shell is interpreting characters wrongly.

Here's what I see (plese note the last 3 lines):

$ ipython
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
Type "copyright", "credits" or "license" for more information.

IPython 5.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

^[[?12l^[[?25hprint("hi")
^[[J^[[?7h^[[?12l^[[?25h^[[?2004lhi

^[[?12l^[[?25h

I believe this must be some encoding problem, but I'm not sure how to diagnose and fix it.

Here's my env output if it helps:

$ env
XDG_VTNR=2
XDG_SESSION_ID=c3
TERM=xterm-256color
SHELL=/bin/bash
XDG_MENU_PREFIX=gnome-
VTE_VERSION=4402
GJS_DEBUG_OUTPUT=stderr
WINDOWID=29360134
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
USER=adrin
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
SESSION_MANAGER=local/mydarlingarch:@/tmp/.ICE-unix/498,unix/mydarlingarch:/tmp/.ICE-unix/498
USERNAME=adrin
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
MAIL=/var/spool/mail/adrin
DESKTOP_SESSION=gnome
QT_QPA_PLATFORMTHEME=qgnomeplatform
XDG_SESSION_TYPE=x11
PWD=/home/adrin
LANG=en_US.UTF-8
GDM_LANG=en_US.UTF-8
GDMSESSION=gnome
XDG_SEAT=seat0
HOME=/home/adrin
SHLVL=1
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
XDG_SESSION_DESKTOP=gnome
LOGNAME=adrin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
WINDOWPATH=2
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0
XDG_CURRENT_DESKTOP=GNOME
COLORTERM=truecolor
XAUTHORITY=/run/user/1000/gdm/Xauthority
_=/usr/bin/env
adrin
  • 4,511
  • 3
  • 34
  • 50
  • 1
    If you run this: `echo -e '\033[0;31mhello\033[1;0m'`, do you get a red "hello", or garbled text? Trying to tell if it's ipython or your whole shell. If you run `shell` instead of `eshell`, do you see the same thing? Finally, if you're fine using ipython without colors, just run `ipython --colors=NoColor`. – Brian Malehorn Jul 25 '16 at 23:23
  • Trying in `shell` prints a red "hello", the `eshell` prints the exact same string, as if it's not parsing it. But the ipython has the same problem in both. And `--colors=NoColor` doesn't help, same result. – adrin Jul 27 '16 at 11:50
  • And I have two `ipython`s, one is 2.4, the other one 5. I don't have the problem with the old one. The new one is what I have in my virtualenv. – adrin Jul 27 '16 at 12:02
  • 1
    OK, since `--colors=NoColor` didn't help, that means it's not a color thing, the `echo` difference is a red herring. The issue you're running into is that ipython is trying to send terminal control codes - to redraw the screen, draw autocomplete information, etc. Emacs shell doesn't understand these, this is why you can't run `man` or `less` in an Emacs shell. Sadly there's no general fix for this, just use a separate shell. Your best bet is to look through `ipython --help` and try to find an option that disables this autocomplete. – Brian Malehorn Jul 27 '16 at 20:21

1 Answers1

3

Thanks to @brian-malehorn, the problem was indeed the control characters sent by ipython.

This could be checked by trying to echo a colored text using echo -e '\033[0;31mhello\033[1;0m', which in my case printed a colored text. If the problem was the colored text, it could be fixed by:

ipython --colors=NoColor

My problem however, was not the above, therefore it must have been control characters sent by ipython to the shell. This can be disabled using:

ipython --simple-prompt
adrin
  • 4,511
  • 3
  • 34
  • 50