Silex / docker.el

Manage docker from Emacs.
738 stars 73 forks source link

docker run: PS1 bash colors don't display properly #9

Closed mikefaille closed 8 years ago

mikefaille commented 9 years ago

This is what I see when I try to have an interactive output.

http://pastebin.com/gtkHBb2n

(github markdown interpret these characters chains ...)

Silex commented 9 years ago

Hello,

Those are color escape code... can you explain exactly what you do to trigger this?

For example, if I select the unbutu:latest image and press R R bash RET I enter a bash prompt, and then type ls -alh --color it works fine...

That said, I agree that the current implementation is to simple. See #7 for what will probably happen in the future.

mikefaille commented 9 years ago

Ah, I use https://github.com/bbatsov/solarized-emacs as theme.

My ubuntu promt : http://pastebin.com/9DNGzUgR

Silex commented 9 years ago

I think I found the issue... Please try this:

(ansi-color-for-comint-mode-on)

Inside your .emacs file.

If that fixes it for you, I'll make a commit.

mikefaille commented 9 years ago

It dont work. I had (ansi-color-for-comint-mode-on) in my ~/.emacs.d/init.el Recompile this file. Restart emacs.

And, when I docker exec, it dont work :-/

I tried M-: command to exec (ansi-color-for-comint-mode-on) in same docker tty buffer too.

If you want a preview : http://postimg.org/image/wfqxnq10p/

Hum, if I tap after ls, ls output change for http://pastebin.com/8Ysfdb9B

instead of : http://pastebin.com/gtkHBb2n

Silex commented 9 years ago

Weird. What is your emacs version?

Can't you try the following steps and report:

Also, I see from your screenshot that sometimes it works sometimes not. Try typing "reset" and "clear" when that happens to see if it repairs it.

mikefaille commented 9 years ago

Crap, it work better.

]0;root@b4fea5b723d0: /root@b4fea5b723d0:/# 

]0;root@b4fea5b723d0: /root@b4fea5b723d0:/# ls
ls
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr
]0;root@b4fea5b723d0: /root@b4fea5b723d0:/# 

]0;root@b4fea5b723d0: /root@b4fea5b723d0:/# ls
ls
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr
]0;root@b4fea5b723d0: /root@b4fea5b723d0:/# ps aux
ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.2  0.0  18172  3328 ?        Ss   18:46   0:00 bash
root        17  0.0  0.0  15572  2164 ?        R+   18:46   0:00 ps aux
]0;root@b4fea5b723d0: /root@b4fea5b723d0:/# 
Silex commented 9 years ago

Hum, what is your PROMPT? is your shell bash?

mikefaille commented 9 years ago

Yes, this is the default bash from ubuntu:latest

Silex commented 9 years ago

Weird. What is your emacs version?

Can you answer this? :)

mikefaille commented 9 years ago

Heh^ Compiled from master : GNU Emacs 25.0.50.4 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.2) of 2015-05-03

Silex commented 9 years ago

Haha! I was able to reproduce the weirdness!

Basically, only ubuntu:latest misbehave... fedora:latest or debian:jessie behave fine

I'll investiguate, but it looks like a PS1 issue.

mikefaille commented 9 years ago

Allright ! Did you check centos:7 too ? That was my 1st test.

Silex commented 9 years ago

Yep, same problem.

Silex commented 9 years ago

Okay... the problem is pretty funny and I'm not sure how to solve it "the right way".

Basically, PS1 is set like if the terminal had full color support. This is logical because docker run emulates a terminal... and then it is displayed inside emacs which doens't have full color support.

The simplest fix right now is to type the following inside the bash session:

export PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
Silex commented 9 years ago

Other workaround:

export TERM=dumb; bash

Or from withing docker-run:

R R sh -c "export TERM=dumb bash" RET

Silex commented 8 years ago

Ok, simply use the following when running images:

R =e TERM=dumb RET R

mikefaille commented 8 years ago

I'll test it. Thank you !