forked from samrocketman/home
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·86 lines (79 loc) · 2.63 KB
/
setup.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#Sam Gleske home setup script
#Ubuntu 14.04 LTS \n \l
#Linux 3.13.0-24-generic x86_64
#GNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)
#
# HOME REPOSITORY CONFIGURATION AND SAFETY CHECKS
#
PROJECT_HOME="${PROJECT_HOME:-${HOME}/git/home}"
if [ -d "${PROJECT_HOME}" -a ! -d "${HOME}/git/github/home" ]; then
mkdir -p "${HOME}/git/github"
ln -s ${PROJECT_HOME} ~/git/github/
fi
if [ ! -d "${PROJECT_HOME}" ];then
echo "ERR: home repo not cloned in ~/git?" >&2
exit 1
fi
#
# USE MY DOTFILES
#
#link all dotfiles to $HOME directory
ln -s "${PROJECT_HOME}"/dotfiles/.[a-z]* ~
#if login shell then use .bash_profile
if shopt -q login_shell;then
#yes it is a login shell
grep '\.bashrc_custom' ~/.bash_profile &> /dev/null || echo '. ~/.bashrc_custom' >> ~/.bash_profile
else
#it is not a Mac
grep '\.bashrc_custom' ~/.bashrc &> /dev/null || echo '. ~/.bashrc_custom' >> ~/.bashrc
fi
#
# CONFIGURE GLOBAL GIT SETTINGS
#
#set default user
if ! git config --global -l 2> /dev/null | grep 'user\.email=sam\.mxracer' &> /dev/null; then
echo 'Setting global author to sam.mxracer email.'
git config --global user.name 'Sam Gleske'
git config --global user.email 'sam.mxracer@gmail.com'
fi
#configure the include file
if ! git config --global -l | grep 'include.path=~/\.gitconfig_settings' &> /dev/null; then
echo 'Adding include.path=~/.gitconfig_settings to git settings.'
git config --global --add include.path '~/.gitconfig_settings'
fi
#configure authordomains in git
if ! git config --global --bool authordomains.enabled &> /dev/null; then
echo 'Enable authordomains.'
git config --global authordomains.enabled true
for x in github.com gitlab.com git.gnome.org; do
if ! git config --global -l | grep "^authordomains.${x}" &> /dev/null; then
echo "Setting authordomains.${x}"
git config --global "authordomains.${x}.name" 'Sam Gleske'
git config --global "authordomains.${x}.email" 'sam.mxracer@gmail.com'
fi
done
fi
#copy pre-commit hook into existing git repositories.
#but only if templates are in use
if [ -e "${HOME}/git" -a -n "$(git config --get init.templatedir)" ]; then
(
TEMPLATEDIR="$(eval "echo $(git config --get init.templatedir)")"
cd "${HOME}/git"
find . -type d -name '.git' | while read x;do
if [ ! -e "${x}/hooks/pre-commit" ]; then
cp "${TEMPLATEDIR}/hooks/pre-commit" "${x}/hooks/"
fi
done
)
fi
git config --global authordomains.enabled false
if [ ! -e "$HOME/bin" ]; then
ln -s "$HOME/git/home/bin" "$HOME/bin"
fi
#
# RASPBERRY PI ONLY SETUP
#
if (uname -rms | grep -v 'Darwin' &> /dev/null) && grep -q 'Raspbian' /etc/issue; then
./raspi/setup.sh
fi