-
Notifications
You must be signed in to change notification settings - Fork 3
/
01-homebrew.zsh
39 lines (30 loc) · 1.07 KB
/
01-homebrew.zsh
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
# install Homebrew
log::step "Installing Homebrew"
local brew_prefix="/usr/local"
local brew_repo="/usr/local/Homebrew"
[ -d "$brew_prefix" ] || sudo mkdir -p "$brew_prefix"
[ -d "$brew_repo" ] || sudo mkdir -p "$brew_repo"
sudo chown root:wheel $brew_prefix 2>/dev/null || true
sudo chown -R $USER\:admin $brew_repo || true
for d in Cellar Frameworks bin etc include lib opt sbin share var
do
[ -d $brew_prefix/$d ] || sudo mkdir -p $brew_prefix/$d
sudo chown -R $USER\:admin $brew_prefix/$d
done
(
cd $brew_repo
git init -q
git config remote.origin.url "https://github.com/Homebrew/brew"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git config core.autocrlf "false"
git fetch origin master:refs/remotes/origin/master -n
git reset --hard origin/master
ln -sf $brew_repo/bin/brew $brew_prefix/bin/brew
$brew_prefix/bin/brew update --force
)
# install and upgrade from Brewfile
if [ -f "$HOME/.Brewfile" ]; then
log::step "Installing from Brewfile"
brew bundle check --global || brew bundle --global
log::g "Brews installed/updated"
fi