Handle the .gitconfig-* files in .bashrc.

This commit is contained in:
Darren 'Tadgy' Austin 2023-11-03 21:56:22 +00:00
commit bc6373332e

20
.bashrc
View file

@ -558,6 +558,26 @@ hash ssh ssh-add >/dev/null 2>&1 && ssh() {
command "${_EXEC:-${FUNCNAME[0]}}" "$@" command "${_EXEC:-${FUNCNAME[0]}}" "$@"
} }
# Handle the ~/.gitconfig link.
if [[ -e "$HOME/.gitconfig-$USER@$HOSTNAME" ]]; then
FILENAME=".gitconfig-$USER@$HOSTNAME"
elif [[ -e "$HOME/.gitconfig-$USER@*.${HOSTNAME#*.}" ]]; then
FILENAME=".gitconfig-$USER@*.${HOSTNAME#*.}"
elif [[ -e "$HOME/.gitconfig-$USER@*" ]]; then
FILENAME=".gitconfig-$USER@*"
elif [[ -e "$HOME/.gitconfig-*@$HOSTNAME" ]]; then
FILENAME=".gitconfig-*@$HOSTNAME"
elif [[ -e "$HOME/.gitconfig-*.${HOSTNAME#*.}" ]]; then
FILENAME=".gitconfig-*.${HOSTNAME#*.}"
elif [[ -e "$HOME/.gitconfig-default" ]]; then
FILENAME=".gitconfig-default"
else
(cd "$HOME" && [[ -L ".gitconfig" ]] && rm -f ".gitconfig")
printf "%s: %s\\n" "${BASH_SOURCE##*/}" "failed to update .gitconfig symlink" >&2
fi
[[ -n "$FILENAME" ]] && (cd "$HOME" && ln -sf "$FILENAME" ".gitconfig")
unset FILENAME
# Platform specific set up. # Platform specific set up.
if [[ "$PLATFORM" = "Linux" ]]; then if [[ "$PLATFORM" = "Linux" ]]; then
# Linux specific functions. # Linux specific functions.