如何返回默认的 PS1 提示?

pus*_*pop 4 themes bash

安装 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"
Run Code Online (Sandbox Code Playgroud)

mur*_*uru 6

看起来有些东西修改了你的.bashrc,因为根本没有提到PS1它。目前,请备份.bashrc并恢复原始文件,然后启动一个新的 shell:

cp ~/.bashrc{,.bak}
cp /etc/skel/.bashrc ~/.bashrc
Run Code Online (Sandbox Code Playgroud)

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

问题是,那么 PS1 在哪里设置?也许新的.bashrc正在采购其他文件,所以你应该检查.bashrc.bak看看发生了什么变化。


ter*_*don 6

提示是通过使用PS1变量设置的。这可以根据您的设置在多个地方定义。如果新提示特定于您的用户,您可以运行以下命令来检查它是在哪个文件中定义的:

grep -H PS1 ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login
Run Code Online (Sandbox Code Playgroud)

如果没有返回任何内容,请扩大搜索范围(其中一些文件应该不相关,但这些都是默认 bash 可以读取的所有文件,因此您也可以包括甚至不太可能的罪魁祸首,例如~/.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
Run Code Online (Sandbox Code Playgroud)

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