-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall
executable file
·108 lines (86 loc) · 1.88 KB
/
install
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
# Options
#
# -b, --branch
# Install from a specifiq branch
#
# -s, --skip-clone
# Skip cloning from github
# Platform name
PLATFORM="$(uname -s | tr '[:upper:]' '[:lower:]')"
# All the colors we're using for notifications
SWITCH="\033["
RED="${SWITCH}0;31m"
GREEN="${SWITCH}0;32m"
YELLOW="${SWITCH}1;33m"
NORMAL="${SWITCH}0m"
set -e
echo ''
DEPENDENCIES=(curl git stow)
# Print red
error () {
printf "\r${RED}$1${NORMAL}\n"
exit
}
# Print green
success () {
printf "\r${GREEN}$1${NORMAL}\n"
}
# Print yellow
info () {
printf "\r${YELLOW}$1${NORMAL}\n"
}
# Install suggestion
suggestion () {
if [[ $PLATFORM == "linux" ]]; then
CMD_NAME="sudo apt-get"
else
CMD_NAME="brew"
fi
info "$CMD_NAME install $1"
}
# Fetch dotfiles from github
fetch_dotfiles () {
info "Fetching dotfiles..."
local BRANCH_NAME
# Figure out the branch we're working on
! [[ "$1" ]] && BRANCH_NAME="master" || BRANCH_NAME="$1"
git clone -b $BRANCH_NAME https://github.com/cloverinteractive/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
}
# Exit if installer dependecy is not found
for dependency in "${DEPENDENCIES}"; do
path="$(which ${dependency})"
if [[ ! -x "${path}" ]]; then
info "$dependency was not found in your system"
suggestion $dependency
exit 1
fi
done
# If no arguments where sent clone master
if [ "$#" == "0" ]; then
fetch_dotfiles
fi
# Check arguments
while [ "$#" -gt 0 ]; do
case "$1" in
-b | --branch)
fetch_dotfiles "$2"
shift 2
;;
-s | --skip-clone)
shift 1
;;
* )
error "Unknown option: $1"
exit 1
;;
esac
done
info "Linking dotfiles"
if [[ ! -e "$HOME/.config" ]]; then
mkdir $HOME/.config
fi
stow -v .
success "Thanks for installing, please report any issues to https://github.com/cloverinteractive/dotfiles/issues"
info "Start a new shell to load your new env"