#!/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"