如何返回默认的PS1提示?

在安装docker之后(我肯定认为这是关于docker)我改变了cmd-label 。 例如,它就像username@root8hgf858$: your_command[:/home/username] $

我该如何解决? 我已经检查了系统设置中的当前主题 – 没关系。

截图:

在此处输入图像描述

 [:/home/imran] $ grep PS1 .bashrc /etc/bash.bashrc /etc/skel/.bashrc /etc/bash.bashrc:[ -z "$PS1" ] && return /etc/bash.bashrc:PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' /etc/skel/.bashrc: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' /etc/skel/.bashrc: PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' /etc/skel/.bashrc: PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 

看起来像某个东西或其他东西修改了你的.bashrc ,因为根本没有提到PS1 。 暂时,备份.bashrc并恢复原始内容,然后启动一个新shell:

 cp ~/.bashrc{,.bak} cp /etc/skel/.bashrc ~/.bashrc 

/etc/skel包含用于设置新用户主目录的框架配置文件,因此它应包含您拥有的原始.bashrc

问题是,PS1在哪里设置呢? 也许新的.bashrc正在寻找其他文件,因此您应该检查.bashrc.bak以查看发生了哪些更改。

使用PS1变量设置提示。 这可以在几个地方定义,具体取决于您的设置。 如果新提示特定于您的用户,则可以运行以下命令来检查在其中定义的文件:

 grep -H PS1 ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login 

如果没有返回任何内容,请扩大搜索范围(这些文件中的一些不应该是相关的,但这些是默认情况下可以读取的所有文件,因此您可能包含甚至不太可能的罪魁祸首,例如~/.bash_aliases ):

 grep -H PS1 ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases \ /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null 

识别完文件后,在文本编辑器中打开它,然后将PS1设置为您喜欢的任何内容。