summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/gitconfig.sh29
1 files changed, 29 insertions, 0 deletions
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 @@
1#!/bin/sh
2target=~/.gitconfig
3if [ -z "$OVERWRITE_GITCONFIG" ] && [ -e "$target" ]
4then
5 exit
6fi
7
8user=$(id -un) || exit
9[ "$user" ] || exit
10email=${user}@$(hostname --fqdn) || exit
11[ "$email" ] || exit
12name=$(getent passwd "$user" | cut -d: -f2) || : ok
13temp=$(mktemp ~/.gitconfig.tmp.XXX) || exit
14[ "$temp" ] || exit
15
16gitconfig()
17{
18cat <<END
19[user]
20 email = ${email}
21 name = ${name:-$email}
22[core]
23 excludesfile = ~/.config/git/ignore
24END
25}
26
27gitconfig > "$temp" &&
28 mv "$temp" "$target" ||
29 rm -f "$temp"