only define default functions if setting PS1

This commit is contained in:
Jens Petersen 2023-11-13 12:30:32 +08:00
parent 35ebfe4d05
commit 81ed607e32
2 changed files with 32 additions and 29 deletions

View File

@ -10,8 +10,6 @@ if [ '(' "$PS1" = "[\u@\h \W]\\$ " -o "$PS1" = "\\s-\\v\\\$ " ')' -a "${TERM: -5
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"
@ -39,3 +37,5 @@ prompt_default_os() {
PROMPT_START=''
PROMPT_END=''
}
fi

View File

@ -1,6 +1,6 @@
Name: shell-color-prompt
Version: 0.3
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
* Mon Nov 13 2023 Jens Petersen <petersen@redhat.com> - 0.3-2
- only define default functions if setting PS1
* Mon Nov 13 2023 Jens Petersen <petersen@redhat.com> - 0.3-1
- add PROMPT_SEPARATOR and PROMPT_DIRECTORY default variables (#2239152)
- add optional PROMPT_START and PROMPT_END (replaces PROMPT_BRACKETS)