-
Notifications
You must be signed in to change notification settings - Fork 0
/
brew
executable file
·156 lines (127 loc) · 2.94 KB
/
brew
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/sh
pp() {
local fmt="$1"; shift
printf "\n$fmt\n" "$@"
}
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
if [ ! -f "$HOME/.zshrc" ]; then
touch "$HOME/.zshrc"
fi
case "$SHELL" in
*/zsh) : ;;
*)
pp "Changing your shell to zsh..."
chsh -s "$(which zsh)"
;;
esac
brew() {
if is_installed "$1"; then
if is_upgradable "$1"; then
pp "Upgrading %s ..." "$1"
command brew upgrade "$@"
else
pp "Already using the latest version of %s. Skipping..." "$1"
fi
else
pp "Installing %s..." "$1"
command brew install "$@"
fi
}
is_installed() {
local name="$(expand_alias "$1")"
command brew list -1 | grep -Fqx "$name"
}
is_upgradable() {
local name="$(expand_alias "$1")"
! command brew outdated --quiet "$name" >/dev/null
}
tap() {
command brew tap "$1" 2> /dev/null
}
expand_alias() {
command brew info "$1" 2>/dev/null | head -1 | awk '{gsub(/:/, ""); print $1}'
}
# FIXME: This doesn't work if package is up to date
gem() {
if command gem list "$1" --installed > /dev/null; then
pp "Updating %s..." "$1"
command gem update "$1"
else
pp "Installing %s..." "$1"
command gem install "$@"
fi
}
if ! command -v brew >/dev/null; then
pp "Installing Homebrew..."
curl -fsS \
'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby
export PATH="/usr/local/bin:$PATH"
else
pp "Homebrew already installed. Skipping..."
fi
pp "Updating Homebrew formulas..."
command brew update
pp "Installing OS tools..."
brew 'coreutils'
brew 'tree'
brew 'git'
brew 'watch'
tap 'jhawthorn/fzy'
brew 'fzy'
brew 'fzf' # Need this for gh-branch.
brew 'the_silver_searcher'
brew 'ripgrep'
brew 'vim'
brew 'tmux'
brew 'ctags'
brew 'openssl'
brew 'libyaml'
# Nokogiri deps
brew 'libxml2'
brew 'libxslt'
pp "Installing Development tools..."
tap 'homebrew/core'
brew 'yarn'
brew 'node'
npm install -g n
brew 'redis'
brew 'postgresql'
brew 'shared-mime-info'
brew 'imagemagick'
# Setup Terminus font
tap 'homebrew/cask-fonts'
brew 'font-terminus'
# Setup Heroku CLI
tap 'heroku/brew'
brew 'heroku'
# Setup Ruby
brew 'chruby'
brew 'ruby-install'
pp "Installing Ruby..."
# TODO: Setup the current stable version as default by writing it to
# $HOME/.ruby-version
ruby-install ruby --no-reinstall
if [ Darwin = `uname` ]; then
source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
source /opt/homebrew/opt/chruby/share/chruby/auto.sh
else
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
fi
chruby ruby # FIXME: this probably won't select the right one if > 1
# Personal tools
pp "Installing personal packages..."
# Gems
gem 'teamocil'
gem 'gist'
gem 'ripper-tags'
pp "Configuring Bundler..."
number_of_cores=$(sysctl -n hw.ncpu)
bundle config --global jobs $(expr $number_of_cores - 1)
if [ -f "$HOME/.laptop.local" ]; then
. "$HOME/.laptop.local"
fi