-
Notifications
You must be signed in to change notification settings - Fork 0
/
homebrew.sh
executable file
·46 lines (41 loc) · 1.32 KB
/
homebrew.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
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")" \
&& . "../../utils.sh" \
&& . "./utils.sh"
get_homebrew_git_config_file_path() {
local path=""
if path="$(brew --repository 2> /dev/null)/.git/config"; then
printf "%s" "$path"
return 0
else
print_error "Homebrew (get config file path)"
return 1
fi
}
install_homebrew() {
if ! cmd_exists "brew"; then
printf "\n" | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" &> /dev/null
# └─ simulate the ENTER keypress
fi
print_result $? "Homebrew"
}
opt_out_of_analytics() {
local path=""
# Try to get the path of the `Homebrew` git config file.
path="$(get_homebrew_git_config_file_path)" \
|| return 1
# Opt-out of Homebrew's analytics.
# https://github.com/Homebrew/brew/blob/0c95c60511cc4d85d28f66b58d51d85f8186d941/share/doc/homebrew/Analytics.md#opting-out
if [ "$(git config --file="$path" --get homebrew.analyticsdisabled)" != "true" ]; then
git config --file="$path" --replace-all homebrew.analyticsdisabled true &> /dev/null
fi
print_result $? "Homebrew (opt-out of analytics)"
}
main() {
print_in_purple "\n Homebrew\n\n"
install_homebrew
opt_out_of_analytics
brew_update
brew_upgrade
}
main