shell-color-prompt/bash-color-prompt.sh
Jens Petersen 27cb5add3f add PROMPT_SEPARATOR, PROMPT_DIRECTORY, and PROMPT_START/PROMPT_END (#2239152)
With thanks to Thomas M Steenholdt for suggesting and pushing for this
2023-11-13 11:15:56 +08:00

14 lines
608 B
Bash

# see /usr/share/doc/bash-color-prompt/README.md
## to truncate \w dirpath set:
# PROMPT_DIRTRIM=3
# only set for color terminals and if PS1 unchanged from bash or fedora defaults
if [ '(' "$PS1" = "[\u@\h \W]\\$ " -o "$PS1" = "\\s-\\v\\\$ " ')' -a "${TERM: -5}" = "color" -o -n "${prompt_color_force}" ]; then
PROMPT_SEPARATOR=':'
PROMPT_DIRECTORY='\w'
PS1='${PROMPT_START@P}\[\e[${PROMPT_COLOR:-32}m\]${container:+⬢ }\u@\h\[\e[0m\]${PROMPT_SEPARATOR@P}\[\e[${PROMPT_DIR_COLOR:-${PROMPT_COLOR:-32}}m\]${PROMPT_DIRECTORY@P}${PROMPT_ERROR:+\[\e[0;31m\]${?#0}}\[\e[0m\]${PROMPT_END@P}\$ '
fi