* Re: [gentoo-user] New bashrc
2024-07-06 14:34 [gentoo-user] New bashrc Peter Humphrey
@ 2024-07-06 16:31 ` Dale
2024-07-06 23:10 ` Peter Humphrey
0 siblings, 1 reply; 4+ messages in thread
From: Dale @ 2024-07-06 16:31 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]
Peter Humphrey wrote:
> Hello list,
>
> Would someone please either post the new bashrc file here or send me a copy,
> in which genfun_has_readline is defined? I seem to have lost mine altogether. I
> think portage may be being too clever in remembering config files that I've not
> allowed it to update previously, and so not offering to update it now.
>
> I mean app-shells/bash-5.2_p26-r6.
>
> Many thanks.
>
I think this gives the new config files. I save the binaries that
emerge creates. I found the new bash and extracted the config files.
The ones that start with a number are in the bashrc.d directory. They
are attached.
I might add, after the update, I had issues with my PS1 and alias
settings. My main rig went rather well given it has been through a few
updates. The new rig however was like pulling teeth. I ended up
copying the /etc/bash directory from my main rig. Then it worked.
Using dispatch-conf and me rarely being able to use it correctly is
causing problems. I need to find a better tool. Thing is, I don't
think one exists. I'd encourage you to use the bashrc.d directory when
possible. That way your settings aren't mixed in with defaults.
Hope those files help.
Dale
:-) :-)
[-- Attachment #2: 10-gentoo-color.bash --]
[-- Type: text/plain, Size: 2209 bytes --]
# /etc/bash/bashrc.d/10-gentoo-color.bash
if [[ ${NO_COLOR} ]]; then
# Respect the user's wish not to use color. See https://no-color.org/.
gentoo_color=0
elif [[ ${COLORTERM@a} == *x* && ${COLORTERM} == @(24bit|truecolor) ]]; then
# The COLORTERM environment variable can reasonably be trusted here.
# See https://github.com/termstandard/colors for further information.
gentoo_color=1
elif unset -v COLORTERM; ! gentoo_color=$(tput colors 2>/dev/null); then
# Either ncurses is not installed or no terminfo database could be
# found. Fall back to a whitelist which covers the majority of terminal
# emulators and virtual console implementations known to support color
# 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* |\
tmux* |\
wsvt25* ) gentoo_color=1
esac
elif (( gentoo_color == 16777216 )); then
# Truecolor support is available. Advertise it.
export COLORTERM=truecolor
fi
# For direxpand to be missing indicates that bash is lacking readline support.
if (( gentoo_color <= 0 )) || [[ ! $(shopt -p direxpand 2>/dev/null) ]]; then
# Define a prompt without color.
PS1='\u@\h \w \$ '
elif (( EUID == 0 )); then
# If root, omit the username and print the hostname in red.
PS1='\[\e[01;31m\]\h\[\e[01;34m\] \w \$\[\e[00m\] '
else
# Otherwise, print the username and hostname in green.
PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[00m\] '
fi
if (( gentoo_color > 0 )); then
# 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
# Enable colors for ls(1) and some other utilities that respect the
# LS_COLORS variable. Prefer ~/.dir_colors, per bug #64489.
if hash dircolors 2>/dev/null; then
if [[ -f ~/.dir_colors ]]; then
eval "$(dircolors -b -- ~/.dir_colors)"
elif [[ -f /etc/DIR_COLORS ]]; then
eval "$(dircolors -b /etc/DIR_COLORS)"
else
eval "$(dircolors -b)"
fi
fi
fi
unset -v gentoo_color
[-- Attachment #3: 10-gentoo-title.bash --]
[-- Type: text/plain, Size: 1851 bytes --]
# /etc/bash/bashrc.d/10-gentoo-title.bash
genfun_set_win_title() {
# Assigns the basename of the current working directory, having
# sanitised it with @Q parameter expansion. Useful for paths containing
# newlines and such. As a special case, names consisting entirely of
# graphemes shall not undergo the expansion, for reasons of cleanliness.
genfun_sanitise_cwd() {
_cwd=${PWD##*/}
if [[ ! ${_cwd} ]]; then
_cwd=${PWD}
elif [[ ${_cwd} == *[![:graph:]]* ]]; then
_cwd=${_cwd@Q}
fi
}
# Sets the window title with the Set Text Parameters sequence. For
# screen, the sequence defines the hardstatus (%h) and for tmux, the
# pane_title (#T). For graphical terminal emulators, it is normal for
# the title bar to be affected.
genfun_set_win_title() {
genfun_sanitise_cwd
printf '\033]2;%s@%s - %s\007' "${USER}" "${HOSTNAME%%.*}" "${_cwd}"
}
genfun_set_win_title
}
# If the TTY is that of sshd(8) then proceed no further. Alas, there exist many
# operating environments in which the window title would otherwise not be
# restored upon ssh(1) exiting. Users wishing to coerce the historical
# behaviour have the option of setting PROMPT_COMMAND=(genfun_set_win_title).
if [[ ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; then
return
fi
# Determine whether the terminal can handle the Set Text Parameters sequence.
# The only terminals permitted here are those for which there is empirical
# evidence that the sequence is supported and that the UTF-8 character encoding
# is handled correctly. Quite rightly, this precludes many vintage terminals.
# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
case ${TERM} in
alacritty |\
foot* |\
rxvt-unicode* |\
screen* |\
st-256color |\
tmux* |\
xterm* )
PROMPT_COMMAND+=('genfun_set_win_title')
esac
[-- Attachment #4: 15-gentoo-bashrc-check.bash --]
[-- Type: text/plain, Size: 1002 bytes --]
# /etc/bash/bashrc.d/15-gentoo-bashrc-check.bash
# Some users have ~/.bashrc as a copy of ${FILESDIR}/bashrc which either matches
# exactly or is only trivially modified. Such is an improper state of affairs
# and results in the bashrc.d drop-ins being sourced twice. Warn them that they
# should use the skeleton file instead. This drop-in should be removed no sooner
# than one year from the date of its introduction.
if [[ -e ${TMPDIR:-/tmp}/.gentoo-bashrc-check-${EUID} || ! -f ~/.bashrc ]]; then
return
fi
{
if grep -qxF 'for sh in /etc/bash/bashrc.d/* ; do' -- ~/.bashrc; then
cat >&3 <<'EOF'
WARNING! Your ~/.bashrc file is based on an old copy of /etc/bash/bashrc, which
is not intended for use within a home directory. Please either delete ~/.bashrc
or replace it with a copy of /etc/skel/.bashrc before optionally customizing it
further. Neglecting to do so may result in bash behaving unexpectedly.
EOF
fi
touch -- "${TMPDIR:-/tmp}/.gentoo-bashrc-check-${EUID}"
} 3>&2 2>/dev/null
[-- Attachment #5: bash_logout --]
[-- Type: text/plain, Size: 205 bytes --]
# /etc/bash/bash_logout
# This file is sourced when a login shell terminates.
# You may wish to clear everyone's screen when they logout.
#clear
# Or maybe you want to leave a thoughtful note.
#fortune
[-- Attachment #6: bashrc --]
[-- Type: text/plain, Size: 894 bytes --]
# /etc/bash/bashrc
# Proceed no further in the case of a non-interactive shell.
if [[ $- != *i* ]]; then
return
fi
# Disable errexit in case the user enabled it then chose to re-source this file.
shopt -u -o errexit
# Disable completion when the input buffer is empty. Mute STDERR because this
# option is only present in the case that bash was built with readline support.
shopt -s no_empty_cmd_completion 2>/dev/null &&
# Append to HISTFILE rather than overwrite upon exiting, per bug #139609. This
# option also requires for bash to have been built with readline support.
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
^ permalink raw reply [flat|nested] 4+ messages in thread