我注意到在~/.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并决定标题。
但是它们都更改了相同的环境变量,所以当终端启动并“看到”为提示符的文本设置PS1时,它如何也可以设置标题?~/.bashrc是否被加载了两次?
发布于 2020-12-18 07:28:20
第一个条件根据是否启用$PS1来设置$color_prompt。第二个赋值扩展了这一点,将$PS1设置为包含前一个值的表达式。
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h:\w\a\]$PS1"
# Here ---------------------------------------------------^https://stackoverflow.com/questions/65353170
复制相似问题