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

23 lines
1.0 KiB
Bash
Raw Normal View History

## to truncate \w dirpath set:
2023-08-21 15:42:22 +00:00
# PROMPT_DIRTRIM=4
# See <https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters> for ANSI codes
# 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
2023-08-21 15:42:22 +00:00
# examples:
# PROMPT_COLOR=0 # disable colors/attribs
# PROMPT_COLOR=1 # bold prompt
# PROMPT_COLOR=2 # dim prompt
# PROMPT_COLOR=4 # underline prompt
# PROMPT_COLOR='2;7' # dim reverse video
# PROMPT_COLOR='42' # green background
# PROMPT_COLOR='53' # overline separator
# PROMPT_COLOR='1;33;44' # bold yellow on blue
# PROMPT_COLOR='1;32' # bold green
# PROMPT_COLOR='' # unset defaults to green
2023-11-11 10:00:34 +00:00
PS1='${PROMPT_BRACKETS:+[}\[\e[${PROMPT_COLOR:-32}m\]${container:+⬢ }\u@\h\[\e[0m\]:\[\e[${PROMPT_DIR_COLOR:-${PROMPT_COLOR:-32}}m\]\w${PROMPT_ERROR:+\[\e[0;31m\]${?#0}}\[\e[0m\]${PROMPT_BRACKETS:+]}\$ '
2023-08-21 15:42:22 +00:00
fi