From 75f56530c39c723c91b36cba1191151ea68a4bbb Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Fri, 10 Nov 2023 15:08:18 +0800 Subject: [PATCH] also check for bash default prompt for login shell by Sam Morris (#2248853) --- README.md | 2 +- bash-color-prompt.sh | 6 +++--- shell-color-prompt.spec | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fa585d7..2db3c73 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ which otherwise defaults to `PROMPT_COLOR`. Set `prompt_color_force` (before source'ing) to force usage/updating of color PS1: by default it is only setup cautiously if `$TERM` ends in "color" -*and* PS1 is the fedora default. +*and* PS1 is the fedora or bash default. Also you can set `PROMPT_ERROR` if you want to append red error exit code to the prompt. diff --git a/bash-color-prompt.sh b/bash-color-prompt.sh index b95b8c5..6dc66d3 100644 --- a/bash-color-prompt.sh +++ b/bash-color-prompt.sh @@ -1,10 +1,10 @@ -## to shorten \w dirpath: +## to truncate \w dirpath set: # PROMPT_DIRTRIM=4 # See for ANSI codes -# only set for color terminals and if PS1 unchanged -if [ "$PS1" = "[\u@\h \W]\\$ " -a "${TERM: -5}" = "color" -o -n "${prompt_color_force}" ]; then +# 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 # examples: # PROMPT_COLOR=0 # disable colors/attribs # PROMPT_COLOR=1 # bold prompt diff --git a/shell-color-prompt.spec b/shell-color-prompt.spec index ec37e00..a3fa2ac 100644 --- a/shell-color-prompt.spec +++ b/shell-color-prompt.spec @@ -43,6 +43,7 @@ install -m 644 -D -t %{buildroot}%{profiledir} bash-color-prompt.sh %changelog * Fri Nov 10 2023 Jens Petersen - 0.2-1 - add PROMPT_DIR_COLOR to change the dir color (Thomas Steenholdt, #2239152) +- also check for bash default prompt for login shell (Sam Morris, #2248853) * Thu Nov 9 2023 Jens Petersen - 0.1.1-1 - only show error code if PROMPT_ERROR set