我希望创建一个多行变量,它将被分成几行,并在每个新行上进行缩进(不显示缩进)。我已经尝试过几种方法:
function regprompt {
case "$TERM" in
xterm*)
PS1=$(cat <<-EOF
${blue} \u ${txtrst}on ${cyan}\h${white}\$gitps1 ${blue}\${fill} \
${undgrn}\d \D{%r} ${blue}\
\n[ ${yellow}\$newPWD ${blue}] ${txtrst}$ ${blue}
EOF
)
;;
linux*)
PS1="${green} \u ${txtrst}on ${cyan}\h${white}\$gitps1 ${green}\${fill} \
${undgrn}\d \D{%r} ${green}\
\n[ ${yellow}\$newPWD ${green}] ${txtrst}$ ${green}"
;;
screen*)
PS1="${green} \u ${txtrst}on ${cyan}\h${white}\$gitps1 ${green}\${fill} \
${undgrn}\d \D{%r} ${green}\
\n[ ${yellow}\$newPWD ${green}] ${txtrst}$ ${green}"
;;
esac
}
第一个选项显示了日期部分(\d \D{%r})缩进,我只想显示一个空格(在转义符之前的那个)。其他所有内容都正确显示。第二个选项也是如此。屏幕选项将正确显示,我只想知道是否有一种方法可以保持它的组织性?