summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-shells/bash/files')
-rw-r--r--app-shells/bash/files/bashrc-r115
-rw-r--r--app-shells/bash/files/bashrc.d/10-gentoo-color.bash33
2 files changed, 29 insertions, 19 deletions
diff --git a/app-shells/bash/files/bashrc-r1 b/app-shells/bash/files/bashrc-r1
index 61202b61f141..6f4631568119 100644
--- a/app-shells/bash/files/bashrc-r1
+++ b/app-shells/bash/files/bashrc-r1
@@ -5,8 +5,14 @@ if [[ $- != *i* ]]; then
return
fi
-# Disable completion when the input buffer is empty. Requires readline support.
-shopt -s no_empty_cmd_completion 2>/dev/null
+# A convenient function to determine whether bash has readline support.
+genfun_has_readline() [[ $(shopt -p direxpand 2>/dev/null) ]]
+
+# The following two shell options require for bash to have readline support.
+genfun_has_readline &&
+
+# Disable completion when the input buffer is empty.
+shopt -s no_empty_cmd_completion &&
# Append to HISTFILE rather than overwrite upon exiting, per bug #139609.
shopt -s histappend
@@ -14,8 +20,13 @@ shopt -s histappend
# Initialise PROMPT_COMMAND as an array, which is permitted as of bash 5.1.
PROMPT_COMMAND=()
+# Don't let the user influence the order of sourcing for bash 5.3 or greater.
+unset -v GLOBSORT
+
for _ in /etc/bash/bashrc.d/*; do
if [[ $_ == *.@(bash|sh) && -r $_ ]]; then
source "$_"
fi
done
+
+unset -f genfun_has_readline
diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-color.bash b/app-shells/bash/files/bashrc.d/10-gentoo-color.bash
index 66afdcaa9557..6192bfaf4394 100644
--- a/app-shells/bash/files/bashrc.d/10-gentoo-color.bash
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-color.bash
@@ -14,28 +14,27 @@ elif unset -v COLORTERM; ! gentoo_color=$(tput colors 2>/dev/null); then
# and which remain (somewhat) popular. This will rarely happen, so the
# list need not be exhaustive.
case ${TERM} in
- *color* |\
- *direct* |\
- [Ekx]term* |\
- alacritty |\
- aterm |\
- dtterm |\
- foot* |\
- jfbterm |\
- linux |\
- mlterm |\
- rxvt* |\
- screen* |\
- st-256color |\
- tmux* |\
- wsvt25* ) gentoo_color=1
+ *color* |\
+ *direct* |\
+ [Ekx]term* |\
+ alacritty |\
+ aterm |\
+ dtterm |\
+ foot* |\
+ jfbterm |\
+ linux |\
+ mlterm |\
+ rxvt* |\
+ screen* |\
+ tmux* |\
+ wsvt25* ) gentoo_color=1
esac
elif (( gentoo_color == 16777216 )); then
# Truecolor support is available. Advertise it.
export COLORTERM=truecolor
fi
-if (( gentoo_color <= 0 )); then
+if (( gentoo_color <= 0 )) || ! genfun_has_readline; then
# Define a prompt without color.
PS1='\u@\h \w \$ '
elif (( EUID == 0 )); then
@@ -47,7 +46,7 @@ else
fi
if (( gentoo_color > 0 )); then
- # Colorize the output of grep and several coreutils utilities.
+ # Colorize the output of diff(1), grep(1) and a few coreutils utilities.
for _ in diff dir grep ls vdir; do
alias "$_=$_ --color=auto"
done