【发布时间】:2020-12-18 07:24:12
【问题描述】:
我注意到~/.bashrc中有两组PS1:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$'
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h:\w\a\]$PS1"
;;
*)
;;
esac
第一个检查 $color_prompt 是否为真,并决定 提示文本。
第二个检查$TERM 并决定title。
但是它们都改变了 same 环境变量,所以当终端启动并“看到”PS1 设置为 提示文本 时,如何它也可以设置标题? ~/.bashrc 是否被加载了两次?
【问题讨论】: