From 10c5c4b86da22924acebad0e3922e093fa4e158a Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Thu, 9 Nov 2023 22:49:51 +0800 Subject: [PATCH] fixup PROMPT_ERROR change to include the red color code --- README.md | 10 ++++++++-- bash-color-prompt.sh | 2 +- shell-color-prompt.spec | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8db2ca5..eefd77d 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,15 @@ the `PROMPT_COLOR` envvar. For example `PROMPT_COLOR='2;7'` is dim inverse-video and `PROMPT_COLOR='1;33;53'` is bright/bold yellow with overline. -Set `prompt_color_force` to force usage/updating of color PS1: +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 default. + +Also set `PROMPT_ERROR` if you want to append red error exit codes to the prompt. + +See `/etc/profile.d/bash-color-prompt.sh` for the actual script. + +Please report bugs against [shell-color-prompt](https://src.fedoraproject.org/rpms/shell-color-prompt). ## References See etc for the ANSI codes. diff --git a/bash-color-prompt.sh b/bash-color-prompt.sh index 5d23a9c..1ee2f65 100644 --- a/bash-color-prompt.sh +++ b/bash-color-prompt.sh @@ -16,5 +16,5 @@ if [ "$PS1" = "[\u@\h \W]\\$ " -a "${TERM: -5}" = "color" -o -n "${prompt_color_ # PROMPT_COLOR='1;33;44' # bold yellow on blue # PROMPT_COLOR='1;32' # bold green # PROMPT_COLOR='' # unset defaults to green - PS1='\[\e[${PROMPT_COLOR:-32}m\]\u@\h\[\e[0m\]:\[\e[${PROMPT_COLOR:-32}m\]\w\[\e[0;31m\]${PROMPT_ERROR:+${?#0}}\[\e[0m\]\$ ' + PS1='\[\e[${PROMPT_COLOR:-32}m\]\u@\h\[\e[0m\]:\[\e[${PROMPT_COLOR:-32}m\]\w${PROMPT_ERROR:+\[\e[0;31m\]${?#0}}\[\e[0m\]\$ ' fi diff --git a/shell-color-prompt.spec b/shell-color-prompt.spec index 9fbd441..97e4152 100644 --- a/shell-color-prompt.spec +++ b/shell-color-prompt.spec @@ -1,6 +1,6 @@ Name: shell-color-prompt Version: 0.1.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Color prompt for bash shell License: GPL-2.0-or-later @@ -41,6 +41,9 @@ install -m 644 -D -t %{buildroot}%{profiledir} bash-color-prompt.sh %changelog +* Thu Nov 9 2023 Jens Petersen - 0.1.1-2 +- fixup PROMPT_ERROR change to include the red color code + * Thu Nov 9 2023 Jens Petersen - 0.1.1-1 - only show error code if PROMPT_ERROR set