From 9fbd4a9ea4ce0ef8df6b661b0858bfb16ba8d326 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 28 May 2020 18:20:35 -0400 Subject: Dynmically generate ~/.gitconfig Ancient versions of 'git' would use the unix passwd identity as the default author/committer. This dynamically-generated ~/.gitconfig does the same. Might as well set excludesfile = ~/.config/git/ignore --- src/gitconfig.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 src/gitconfig.sh (limited to 'src') diff --git a/src/gitconfig.sh b/src/gitconfig.sh new file mode 100755 index 0000000..3a7e824 --- /dev/null +++ b/src/gitconfig.sh @@ -0,0 +1,29 @@ +#!/bin/sh +target=~/.gitconfig +if [ -z "$OVERWRITE_GITCONFIG" ] && [ -e "$target" ] +then + exit +fi + +user=$(id -un) || exit +[ "$user" ] || exit +email=${user}@$(hostname --fqdn) || exit +[ "$email" ] || exit +name=$(getent passwd "$user" | cut -d: -f2) || : ok +temp=$(mktemp ~/.gitconfig.tmp.XXX) || exit +[ "$temp" ] || exit + +gitconfig() +{ +cat < "$temp" && + mv "$temp" "$target" || + rm -f "$temp" -- cgit v1.2.3