A minor annoyance of running "rails console" inside Emacs
If you run "rails console" from within Emacs, you might have been annoyed by the output that contains control characters whenever you run a query. Like the one given below:
1.9.3-p125 :001 > BlogPost.all
^[[1m^[[36mBlogPost Load (0.2ms)^[[0m ^[[1mSELECT "blog_posts".* FROM "blog_posts" ^[[0m
I could not find a satisfactory solution for this anywhere. So I came up with the following solution that works fine for me.
What this code does is to make use of "term" instead of "shell" to run the rails console. In term-mode you have better support for rendering these control chars. To make navigation and kill/yank easier, it switches to line-mode. The default mode is char-mode. You can switch between line-mode and char-mode using C-c C-j and C-c C-k respectively. Hope that helps.
Comments
(global-linum-mode)
Set in my config for all other files.
Thank you,
Isaac