-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-config.sh
More file actions
executable file
·56 lines (47 loc) · 1.17 KB
/
git-config.sh
File metadata and controls
executable file
·56 lines (47 loc) · 1.17 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -e
# -*- coding: UTF-8 -*-
## Git config --local user.name and user.email
## options
## -p, --personal User personal email
## -w, --work User work email
# CLInt GENERATED_CODE: start
# info: https://github.com/clobrano/CLInt.git
# No-arguments is not allowed
[ $# -eq 0 ] && sed -ne 's/^## \(.*\)/\1/p' "$0" && exit 1
# Converting long-options into short ones
for arg in "$@"; do
shift
case "$arg" in
"--personal") set -- "$@" "-p";;
"--work") set -- "$@" "-w";;
*) set -- "$@" "$arg"
esac
done
function print_illegal() {
echo "[!] Unexpected flag in command line $*"
}
# Parsing flags and arguments
while getopts 'hpw' OPT; do
case "$OPT" in
h) sed -ne 's/^## \(.*\)/\1/p' "$0"
exit 1 ;;
p) _personal=1 ;;
w) _work=1 ;;
\?) print_illegal "$@" >&2;
echo "---"
sed -ne 's/^## \(.*\)/\1/p' "$0"
exit 1
;;
esac
done
# CLInt GENERATED_CODE: end
if [ -n "$_personal" ]; then
EMAIL="$GIT_PERS_EMAIL"
fi
if [ -n "$_work" ]; then
EMAIL="$GIT_WORK_EMAIL"
fi
set -u
git config --local user.name "Carlo Lobrano"
git config --local user.email "$EMAIL"