-
Notifications
You must be signed in to change notification settings - Fork 1
/
20_osx_homebrew.sh
110 lines (97 loc) · 2.59 KB
/
20_osx_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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
# OSX-only stuff. Abort if not OSX.
is_osx || return 1
# Install Homebrew.
if [[ ! "$(type -P brew)" ]]; then
e_header "Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [[ -x "/opt/homebrew/bin/brew" ]]; then
eval $(/opt/homebrew/bin/brew shellenv)
elif [[ -x "/usr/local/bin/brew" ]]; then
eval $(/usr/local/bin/brew shellenv)
else
e_error "Installing Homebrew failed!"
return 1
fi
fi
# Exit if, for some reason, Homebrew is not installed.
[[ ! "$(type -P brew)" ]] && e_error "Homebrew failed to install." && return 1
e_header "Updating Homebrew"
brew doctor
brew update --force
# Functions used in subsequent init scripts.
# Tap Homebrew kegs.
function brew_tap_kegs() {
kegs=($(setdiff "${kegs[*]}" "$(brew tap)"))
if (( ${#kegs[@]} > 0 )); then
e_header "Tapping Homebrew kegs: ${kegs[*]}"
for keg in "${kegs[@]}"; do
brew tap $keg
done
fi
}
# Install Homebrew recipes.
function brew_install_recipes() {
recipes=($(setdiff "${recipes[*]}" "$(brew list --formula)"))
if (( ${#recipes[@]} > 0 )); then
e_header "Installing Homebrew recipes: ${recipes[*]}"
for recipe in "${recipes[@]}"; do
brew install $recipe
done
fi
}
# Ensure the kegs are installed.
kegs=(
homebrew/cask
homebrew/cask-fonts
)
brew_tap_kegs
# Install recipes
recipes=(
#ansible
brew-gem
cowsay
fish
font-meslo-lg-nerd-font
git
git-extras
htop
id3tool
jq
lesspipe
liquidprompt
locateme
man2html
mackup
maven
menumeters
#mosh
nmap
nvm
omnidisksweeper
ssh-copy-id
starship
sublime-text
terminal-notifier
timelimit
)
brew_install_recipes
# Misc cleanup!
# This is where brew stores its binary symlinks
local binroot="$(brew --config | awk '/HOMEBREW_PREFIX/ {print $2}')"/bin
# htop
if [[ "$(type -P $binroot/htop)" ]] && [[ "$(stat -L -f "%Su:%Sg" "$binroot/htop")" != "root:wheel" || ! "$(($(stat -L -f "%DMp" "$binroot/htop") & 4))" ]]; then
e_header "Updating htop permissions"
sudo chown root:wheel "$binroot/htop"
sudo chmod u+s "$binroot/htop"
fi
# set fish as default shell
if [[ "$(type -P $binroot/fish)" && "$(cat /etc/shells | grep -q "$binroot/fish")" ]]; then
e_header "Adding $binroot/fish to the list of acceptable shells"
echo "$binroot/fish" | sudo tee -a /etc/shells >/dev/null
fi
if [[ "$(dscl . -read ~ UserShell | awk '{print $2}')" != "$binroot/fish" ]]; then
e_header "Making $binroot/fish your default shell"
sudo chsh -s "$binroot/fish" "$USER" >/dev/null 2>&1
e_arrow "Please exit and restart all your shells."
fi