-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathhomebrew.sh
More file actions
executable file
·57 lines (49 loc) · 1.08 KB
/
homebrew.sh
File metadata and controls
executable file
·57 lines (49 loc) · 1.08 KB
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
#!/bin/sh
#
# Homebrew
#
# This installs some of the common dependencies needed (or at least desired)
# using Homebrew.
# Check for Homebrew
set -e
_green() {
printf '\033[1;31;32m%b\033[0m\n' "$1"
}
_red() {
printf '\033[1;31;40m%b\033[0m\n' "$1"
}
_exists() {
cmd="$1"
if [ -z "$cmd" ]; then
_red "Usage: _exists cmd"
return 1
fi
if eval type type >/dev/null 2>&1; then
eval type "$cmd" >/dev/null 2>&1
elif command >/dev/null 2>&1; then
command -v "$cmd" >/dev/null 2>&1
else
which "$cmd" >/dev/null 2>&1
fi
return "$?"
}
main() {
if _exists "brew"; then
_green "Homebrew is already installed.";
return 0;
else
case "$(uname -s)" in
Darwin)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
;;
Linux)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"
;;
*)
_red "Unsupported operating system, Darwin or Linux?";
return 1;
esac
_green "Homebrew successfully installed."
fi
}
main "$@"