-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·79 lines (70 loc) · 2.12 KB
/
install.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
#!/bin/bash
#
LINES="------------------------------------------------------------------------------"
# Begin install
echo "Starting install of global bash settings and global git config"
echo ""
if test -f ~/.bash_profile; then
echo $LINES
echo "WARNING: This will overwrite the exisiting bash_profile file you might have created."
echo $LINES
echo ""
read -p "Would you like to proceed? (y/n)" shouldWeProceed
echo $shouldWeProceed | grep ^[Yy]$
if [ $? -eq 0 ]
then
exit 0; #THE USER WANTS TO CONTINUE
else
exit 1; # THE USER DONT WANT TO CONTINUE SO ROLLBACK
fi
fi
sleep 1
# Copy files
cp .alias.sh ~/
cp .bash-settings.sh ~/
cp .bash_profile ~/
cp .git-alias.sh ~/
cp .git-completion.bash ~/
cp .git-config-setup.sh ~/
cp .git-prompt.sh ~/
echo "[COPIED] git settings and bash files to user directory"
# Copy all hooks from repo to system template
echo -n "Install templates for git hooks? (y/n) "
read installHooks
echo ""
if [[ $installHooks =~ ^[Yy]$ ]]
then
sleep 1
# Create template hooks directory if missing
if [ ! -d ~/.git-templates/hooks ]; then
mkdir -p ~/.git-templates/hooks
echo "[CREATED] directory for storing git hooks"
fi
cp ./git-templates/hooks/* ~/.git-templates/hooks
# git hooks need to be executable
chmod a+x ~/.git-templates/hooks/pre-commit
chmod a+x ~/.git-templates/hooks/pre-push
echo "[ADDED] git hook templates"
echo ""
# Final step is to run `git init` on any exisiting local repos
echo $LINES
echo "NOTE: To use the installed git hooks on an existing local repo, run 'git init'"
echo "New and cloned repos will automatically have these hooks"
echo $LINES
echo ""
# New repos and cloned repos will have these hooks automatically
# after installation
sleep 2
fi
if test -f ~/.git-config-setup.sh; then
. ~/.git-config-setup.sh
fi
# Change to root to load new bash_profile
. ~/.bash_profile
echo "$ADDED_TEXT git-completion.bash"
echo "$ADDED_TEXT git-prompt.sh"
echo "$ADDED_TEXT aliases for terminal commands"
echo "$ADDED_TEXT git aliases"
echo "$ADDED_TEXT Terminal window styles"
echo "[LOADED] bash file to current terminal."
echo "Ready to use!"