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,32 +10,32 @@ if [ '(' "$PS1" = "[\u@\h \W]\\$ " -o "$PS1" = "\\s-\\v\\\$ " ')' -a "${TERM: -5
PROMPT_DIRECTORY='\w' 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}\$ ' 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}\$ '
prompt_default() {
PROMPT_COLOR="$1"
PROMPT_DIR_COLOR="$2"
PROMPT_SEPARATOR=':'
PROMPT_DIRECTORY='\w'
PROMPT_START=''
PROMPT_END=''
}
prompt_traditional() {
PROMPT_COLOR="${1:-0}"
PROMPT_DIR_COLOR="${2}"
PROMPT_SEPARATOR=' '
PROMPT_DIRECTORY='\W'
PROMPT_START='['
PROMPT_END=']'
}
prompt_default_os() {
eval $(grep ANSI_COLOR /etc/os-release)
PROMPT_COLOR="$ANSI_COLOR"
PROMPT_DIR_COLOR="$1"
PROMPT_SEPARATOR=':'
PROMPT_DIRECTORY='\w'
PROMPT_START=''
PROMPT_END=''
}
fi fi
prompt_default() {
PROMPT_COLOR="$1"
PROMPT_DIR_COLOR="$2"
PROMPT_SEPARATOR=':'
PROMPT_DIRECTORY='\w'
PROMPT_START=''
PROMPT_END=''
}
prompt_traditional() {
PROMPT_COLOR="${1:-0}"
PROMPT_DIR_COLOR="${2}"
PROMPT_SEPARATOR=' '
PROMPT_DIRECTORY='\W'
PROMPT_START='['
PROMPT_END=']'
}
prompt_default_os() {
eval $(grep ANSI_COLOR /etc/os-release)
PROMPT_COLOR="$ANSI_COLOR"
PROMPT_DIR_COLOR="$1"
PROMPT_SEPARATOR=':'
PROMPT_DIRECTORY='\w'
PROMPT_START=''
PROMPT_END=''
}

View File

@ -1,6 +1,6 @@
Name: shell-color-prompt Name: shell-color-prompt
Version: 0.3 Version: 0.3
Release: 1%{?dist} Release: 2%{?dist}
Summary: Color prompt for bash shell Summary: Color prompt for bash shell
License: GPL-2.0-or-later License: GPL-2.0-or-later
@ -41,6 +41,9 @@ install -m 644 -D -t %{buildroot}%{profiledir} bash-color-prompt.sh
%changelog %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 * Mon Nov 13 2023 Jens Petersen <petersen@redhat.com> - 0.3-1
- add PROMPT_SEPARATOR and PROMPT_DIRECTORY default variables (#2239152) - add PROMPT_SEPARATOR and PROMPT_DIRECTORY default variables (#2239152)
- add optional PROMPT_START and PROMPT_END (replaces PROMPT_BRACKETS) - add optional PROMPT_START and PROMPT_END (replaces PROMPT_BRACKETS)