emacs: M-x shell and color codes (^[[0G[1])

101 views Asked by At

(Using latest OS X and latest emacs available on homebrew) Inside emacs when I do

M-x shell

And then launch a REPL console with

rails console

I get

bash-3.2$ rails c
Loading development environment (Rails 5.0.0)
^[[0G[1] pry(main)> 

Instead of nice colors, I see ^[[0G[1] How can I fix this?

2

There are 2 answers

0
american-ninja-warrior On

If you have an older version of pry installed, do

bash$ DISABLE_PRY_RAILS=1 rails console

this worked for me

0
Thomas Dickey On

In emacs,

M-x shell

gives you a "dumb" shell which does not interpret escape codes. You could do

M-x term

but should be aware that the escape sequence used by rails is not supported by that, either. It is a control sequence (with an incorrect parameter, by the way) which would move the cursor to the first column — on some terminals, such as xterm.

You'd typically see behavior like that from a hard-coded application, and if you're patient, a bug report to its developer might be productive.

Further reading: