#!/bin/bash - not strictly necessary, but helps nano with syntax highlighting. # Symlink the .gitconfig file to the most specific .gitconfig-* file. if [[ -e "$HOME/.gitconfig-$USER@$HOSTNAME" ]]; then FILE=".gitconfig-$USER@$HOSTNAME" elif [[ -e "$HOME/.gitconfig-$USER@*.${HOSTNAME#*.}" ]]; then FILE=".gitconfig-$USER@*.${HOSTNAME#*.}" elif [[ -e "$HOME/.gitconfig-$USER@*" ]]; then FILE=".gitconfig-$USER@*" elif [[ -e "$HOME/.gitconfig-*@$HOSTNAME" ]]; then FILE=".gitconfig-*@$HOSTNAME" elif [[ -e "$HOME/.gitconfig-*.${HOSTNAME#*.}" ]]; then FILE=".gitconfig-*.${HOSTNAME#*.}" elif [[ -e "$HOME/.gitconfig-default" ]]; then FILE=".gitconfig-default" else (cd "$HOME" && [[ -L ".gitconfig" ]] && rm -f ".gitconfig") printf "%s: %s\\n" "${BASH_SOURCE##*/}" "failed to update .gitconfig symlink" >&2 fi [[ -n "$FILE" ]] && (cd "$HOME" && ln -sf "$FILE" ".gitconfig") unset FILE