Docker bash提示不显示颜色 [英] Docker bash prompt not display color

查看:2783
本文介绍了Docker bash提示不显示颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用命令: docker运行--rm -it govim bash -l <​​/ code>运行docker映像,但
它不能显示bash提示颜色。如果我 source〜/ .bash_profile 或再次运行 bash -l <​​/ code>,bash提示显示颜色正常。



Bash提示图片



我的bash_profile和bash_prompt

解决方案

由于 chepner 已评论(较早的回答),。 bash_profile 来源(它是一个交互式shell),因为 bash_prompt .bash_profile 调用。



docker issue 9299 说明 TERM doesn' Ť似乎立即设置,强制用户打开另一个bash:

  docker exec -ti test env TERM = xterm bash -l 

issue 8755



To 说明/重现问题

  docker exec -ti $ CONTAINER_NAME tty 
不是tty

目前的解决方法是:

  docker exec -ti`your_container_id`脚本-q -c/ bin / bash/ dev / null 
/ pre>

两个都假设你先运行一个运行容器,这可能不方便。






T他 OP SolomonT 报告说 docker run with env 做工作:

  docker run -rm -it -eTERM = xterm-256colorgovim bash -l 






Fernando Correia 添加了在评论


为了获得颜色支持并使tmux工作,我结合了两个例子:




  docker exec -it my-container env TERM = xterm脚本-q -c/ bin / bash/ dev / null 


I use command: docker run --rm -it govim bash -l to run docker images but it cannot display bash prompt color. If I source ~/.bash_profile or run bash -l again, bash prompt display color like normal.

Bash Prompt Image

My bash_profile and bash_prompt

解决方案

As chepner commented (earlier answer), .bash_profile is sourced (itis an interactive shell), since bash_prompt is called by .bash_profile.

But docker issue 9299 illustrates that TERM doesn't seem to be set right away, forcing the users to open another bash with:

docker exec -ti test env TERM=xterm bash -l

You have similar color issues with issue 8755.

To illustrate/reproduce the problem:

docker exec -ti $CONTAINER_NAME tty
not a tty

The current workaround is :

docker exec -ti `your_container_id` script -q -c "/bin/bash" /dev/null

Both are supposing you have a running container first, which might not be convenient here.


The OP SolomonT reports that docker run with env do work:

docker run --rm -it -e "TERM=xterm-256color" govim bash -l


And Fernando Correia adds in the comments:

To get both color support and make tmux work, I combined both examples:

docker exec -it my-container env TERM=xterm script -q -c "/bin/bash" /dev/null

这篇关于Docker bash提示不显示颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆