blob: 3a7e8241febb677172880a95de0c5a3352b80285 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 <<END
[user]
email = ${email}
name = ${name:-$email}
[core]
excludesfile = ~/.config/git/ignore
END
}
gitconfig > "$temp" &&
mv "$temp" "$target" ||
rm -f "$temp"
|