我已经更改了/etc/bashrc
文件。
我注释掉了之前的定义并插入了我自己的定义:
PS1="--bash: (\u@\h:\w) $"
Run Code Online (Sandbox Code Playgroud)
这没有任何影响。当我在命令提示符下进行此更改时,效果很好,但不是永久性的。
/etc/bashrc
是系统设置。更改提示的通常位置是每个用户的文件~/.bashrc
. 您可能已经在那里设置了覆盖系统默认值的设置。将您的提示字符串放入~/.bashrc
.
此外,bash 在处理初始化文件方面有一个怪癖。在/etc/bashrc
和~/.bashrc
文件是只读的未登录shell的bash的互动情况。如果您运行登录 shell,bash 只会读取/etc/profile
, and ~/.bash_profile
(或者~/.profile
如果它不存在)。如果登录 shell 是交互式的,您需要明确地.bashrc
从您的源中获取.bash_profile
:
# Work around a well-known bash design bug: bash does not read .bashrc if
# it is invoked as a login shell.
case "$-" in *i*) if test -r ~/.bashrc; then . ~/.bashrc; fi;; esac
Run Code Online (Sandbox Code Playgroud)