shell-color-prompt/bash-color-prompt.sh

42 lines
1.1 KiB
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
prompt_default() {
PROMPT_COLOR="$1"
PROMPT_DIR_COLOR="$2"
PROMPT_SEPARATOR=':'
PROMPT_DIRECTORY='\w'
PROMPT_START=''
PROMPT_END=''
}
prompt_traditional() {
PROMPT_COLOR="${1:-0}"
PROMPT_DIR_COLOR="${2}"
PROMPT_SEPARATOR=' '
PROMPT_DIRECTORY='\W'
PROMPT_START='['
PROMPT_END=']'
}
prompt_default_os() {
eval $(grep ANSI_COLOR /etc/os-release)
PROMPT_COLOR="$ANSI_COLOR"
PROMPT_DIR_COLOR="$1"
PROMPT_SEPARATOR=':'
PROMPT_DIRECTORY='\w'
PROMPT_START=''
PROMPT_END=''
}