-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·50 lines (40 loc) · 1.08 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
#!/bin/bash
set -e
if [[ -d ~/.git-helpers ]]; then
echo "Updating git-helpers..."
rm -fr ~/.git-helpers
else
echo "Installing git-helpers..."
fi
# download the code
git clone --quiet https://github.com/ibaguio/git-helpers.git ~/.git-helpers
# make sure all helpers are executables
chmod a+x ~/.git-helpers/bin/*
# add git-helpers/bin to PATH
GIT_HELPERS_BIN=~/.git-helpers/bin/
# install to bash
if [[ -f ~/.bashrc ]]; then
grep -qxF "export PATH=\$PATH:`pwd`" ~/.bashrc || cat <<EOT >> ~/.bashrc
# git-helpers
alias g=git
export PATH=\$PATH:$GIT_HELPERS_BIN
EOT
fi
# install to zsh
if [[ -f ~/.zshrc ]]; then
grep -qxF "export PATH=\$PATH:`pwd`" ~/.zshrc || cat <<EOT >> ~/.zshrc
# git-helpers
alias g=git
export PATH=\$PATH:$GIT_HELPERS_BIN
EOT
fi
# include custom aliases to gitconfig if it doesnt exist yet
touch ~/.gitconfig # create ~/.gitconfig if it doesn't exist
cat ~/.gitconfig | grep -q "path = ~/.git-helpers/alias.gitconfig" || {
cat <<EOT >> ~/.gitconfig
[include]
# load custom aliases from git-helpers
path = ~/.git-helpers/alias.gitconfig
EOT
}
echo "Success!!"