From 501831219f340df8f487bbbf1786e7d5bf2fcb9a Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Fri, 10 Nov 2023 15:47:22 +0800 Subject: [PATCH] add PROMPT_BRACKETS to surround the prompt with traditional brackets (based on feedback from Thomas Steenholdt, #2239152) --- README.md | 7 +++++-- bash-color-prompt.sh | 2 +- shell-color-prompt.spec | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2db3c73..4f6619f 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,12 @@ the `PROMPT_COLOR` envvar, and optionally `PROMPT_DIR_COLOR`. For example `PROMPT_COLOR='2;7'` is dim inverse-video and `PROMPT_COLOR='1;33;53'` is bright/bold yellow with overline. -`PROMPT_DIR_COLOR` changes the color of the working directory, +`PROMPT_DIR_COLOR` similarly changes the color of the working directory, which otherwise defaults to `PROMPT_COLOR`. +The prompt can be bracketed to look more like the traditional Fedora prompt +by setting `PROMPT_BRACKETS`. + 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 or bash default. @@ -17,7 +20,7 @@ Also you can set `PROMPT_ERROR` if you want to append red error exit code to the 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). +Please open issues 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 6dc66d3..e78e8ca 100644 --- a/bash-color-prompt.sh +++ b/bash-color-prompt.sh @@ -16,5 +16,5 @@ if [ '(' "$PS1" = "[\u@\h \W]\\$ " -o "$PS1" = "\\s-\\v\\\$ " ')' -a "${TERM: -5 # 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_DIR_COLOR:-${PROMPT_COLOR:-32}}m\]\w${PROMPT_ERROR:+\[\e[0;31m\]${?#0}}\[\e[0m\]\$ ' + PS1='${PROMPT_BRACKETS:+[}\[\e[${PROMPT_COLOR:-32}m\]\u@\h\[\e[0m\]:\[\e[${PROMPT_DIR_COLOR:-${PROMPT_COLOR:-32}}m\]\w${PROMPT_ERROR:+\[\e[0;31m\]${?#0}}\[\e[0m\]${PROMPT_BRACKETS:+]}\$ ' fi diff --git a/shell-color-prompt.spec b/shell-color-prompt.spec index a3fa2ac..8e03c72 100644 --- a/shell-color-prompt.spec +++ b/shell-color-prompt.spec @@ -44,6 +44,8 @@ install -m 644 -D -t %{buildroot}%{profiledir} bash-color-prompt.sh * 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) +- add PROMPT_BRACKETS to surround the prompt with traditional brackets + (based on feedback from Thomas Steenholdt, #2239152) * Thu Nov 9 2023 Jens Petersen - 0.1.1-1 - only show error code if PROMPT_ERROR set