-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·87 lines (69 loc) · 2.27 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
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
[[ -n "$(command -v git 2>/dev/null)" &&
-n "$(command -v ruby 2>/dev/null)" &&
-n "$(command -v gem 2>/dev/null)"
]] || {
echo 'You need `git` and `ruby` installed, yo...'; exit 1
}
function debug-msg {
echo $@ >&2
}
## Look for `brew` in all the usual suspects...
function find-brew {
command -v brew 2>/dev/null || {
for location in "/usr/local" "${XDG-HOME:-$HOME}/.linuxbrew" "/home/linuxbrew/.linuxbrew"; do
if [[ -d "$location" && -x "$location/bin/brew" ]]; then
echo "$location/bin/brew"
return
fi
done
return 1
}
}
## Determine platform (Debian/CentOS/MacOSX/Cygwin) via `$OSTYPE`
function install-brew {
case "$OSTYPE" in
"darwin"*) debug-msg 'I am MacOS X!'
## So install Homebrew already...
/usr/bin/env ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
;;
"linux"*) debug-msg 'True Linux, dog.'
## Thanks, how about some Linuxbrew...
/usr/bin/env ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
;;
## TODO: Do something on Cygwin one day...
"cygwin"*) debug-msg 'I am Cygwin!'
return 1 # not implemented
;;
## TODO: Do something on pure BSD one day...
"bsd"*) debug-msg 'What, BSD?'
return 1 # not implemented
;;
## TODO: Fail miserably?
*) debug-msg 'Who knows?'
return 255 # okay, wtf?
;;
esac
find-brew;
}
find-brew || install-brew
BREW="$(find-brew)"
[[ -z "$BREW" ]] && {
echo 'Cannot find `brew`'
exit 1
}
## - `brew bundle` needs `ruby >2` not installed by Max OSX >_<
## - `Brewfile` lives in `al-the-x/dotfiles` installed via `homeshick`
$BREW install ruby homeshick
## Install and link "castles"...
HOMESHICK="$($BREW --prefix homeshick)/bin/homeshick"
for repo in 'al-the-x/dotfiles'; do
$HOMESHICK clone --batch $repo
done
## LINK ALL THE THINGS!
$HOMESHICK link --batch
## Install formulae listed in `Brewfile` (linked via `homesick`)
$BREW tap homebrew/bundle && $BREW bundle --global
## TODO: Install global npm packages
## TODO: Install global python packages
## TODO: Install global ruby gems