加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – Docker bash提示不显示颜色

发布时间:2020-12-13 18:42:49 所属栏目:Linux 来源:网络整理
导读:我使用命令:docker运行–rm -it go vim bash -l来运行docker映像,但是 它不能显示bash提示颜色.如果我来源?/ .bash_profile或再次运行bash -l,bash提示显示颜色正常. Bash Prompt Image My bash_profile and bash_prompt 解决方法 由于 chepner评论(早期的
我使用命令:docker运行–rm -it go vim bash -l来运行docker映像,但是
它不能显示bash提示颜色.如果我来源?/ .bash_profile或再次运行bash -l,bash提示显示颜色正常.

Bash Prompt Image

My bash_profile and bash_prompt

解决方法

由于 chepner评论(早期的答案),.bash_profile来源(itis是一个交互式shell),因为 bash_prompt是 called by .bash_profile.

但docker issue 9299说明,TERM似乎并没有立即设置,迫使用户打开另一个bash:

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

issue 8755有类似的颜色问题.

到illustrate/reproduce the problem:

docker exec -ti $CONTAINER_NAME tty
not a tty

current workaround是:

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

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

OP SolomonT报道docker runenv做的工作:

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

而Fernando Correia加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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读