-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_brew.sh
More file actions
45 lines (40 loc) · 1.16 KB
/
_brew.sh
File metadata and controls
45 lines (40 loc) · 1.16 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
#!/usr/bin/env bash
IS_BREW_IN_PATH=""
# Add brew to PATH for this session
add_brew_path_to_session() {
[[ -n "$IS_BREW_IN_PATH" ]] && return 0
if [[ -f /home/linuxbrew/.linuxbrew/bin/brew ]]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
IS_BREW_IN_PATH="true"
elif [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
IS_BREW_IN_PATH="true"
elif [[ -f /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
IS_BREW_IN_PATH="true"
fi
}
install_brew() {
add_brew_path_to_session
command -v brew &>/dev/null && {
echo_gray "homebrew already installed"
return 0
}
echo_amber "installing homebrew..."
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
add_brew_path_to_session
}
update_brew() {
echo_gray "updating homebrew packages..."
add_brew_path_to_session
brew update
brew upgrade
brew cleanup
}
brew_install_pkg() {
local items=()
read_package_file_to_array "$1" items
[[ ${#items[@]} == 0 ]] && return
echo_gray "found ${#items[@]} brew packages to install"
brew install -q "${items[@]}"
}