-
Notifications
You must be signed in to change notification settings - Fork 2
/
Brewfile.rb
executable file
·170 lines (150 loc) · 4.28 KB
/
Brewfile.rb
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env ruby
require 'pty'
def prompt(*args)
print(*args)
gets
end
def run_cmd(cmd)
begin
PTY.spawn(cmd) do |stdout, stdin, pid|
begin
stdout.each { |line| print line }
rescue Errno::EIO
puts "Errno:EIO error; process has finished giving output."
end
end
rescue PTY::ChildExited
puts "The child process exited!"
end
end
def run_brew(command, items)
items.each { |item|
if command == 'install' && @packages.include?(item.split(' ')[0])
next
end
run_cmd("brew #{command} #{item}")
}
end
@packages = `brew list -1`.split("\n")
# Get brew!
`which -s brew`
if $?.exitstatus != 0
run_cmd('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
end
# Update existing shells
run_brew('install', [
'bash',
'bash-completion',
'zsh'
])
# Get Preferred Shell
fish = prompt "Use fish Shell? (yes/no) "
if fish == 'yes'
run_brew('tap', ['
brew tap fisherman/tap
'])
run_brew('install', [
'fish',
'fisherman'
])
`echo /usr/local/bin/fish | sudo tee -a /etc/shells && sudo chsh -s /usr/local/bin/fish #{`whoami`}`
else
run_cmd('zsh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"')
`echo /usr/local/bin/zsh | sudo tee -a /etc/shells && sudo chsh -s /usr/local/bin/zsh #{`whoami`}`
end
# Updating System Dependencies
run_brew('tap', ['homebrew/dupes'])
run_brew('install', [
'awk',
'coreutils',
'findutils',
'gnu-sed --with-default-names',
'grep --with-default-names',
'less',
'rsync',
'screen',
'whois',
'vim --override-system-vi',
'wget --with-iri'
])
# System Tools
run_brew('install', [
'htop',
'rename',
'rlwrap',
'pigz',
'trash',
'tree',
'watch'
])
# Development Tools
run_brew('install', ['nvm'])
if fish == 'yes'
run_cmd('fish -c "fisher nvm"')
end
run_brew('install', [
'diff-so-fancy',
'git-lfs',
'imagemagick',
'python',
'sqlite',
'asciinema', # https://asciinema.org/
'ccat', # https://github.com/jingweno/ccat
'git-flow-avh', # https://github.com/petervanderdoes/gitflow-avh
'fpp', # https://github.com/facebook/PathPicker
'httpie', # https://httpie.org/
'hh', # https://github.com/dvorka/hstr
'hub', # https://hub.github.com/
'jq', # https://github.com/stedolan/jq
'mackup', # https://github.com/lra/mackup
'tig', # https://github.com/jonas/tig
'the_silver_searcher', # https://github.com/ggreer/the_silver_searcher
'yank' # https://github.com/mptre/yank
])
run_cmd('pip install -U pip setuptools')
run_cmd("gem install bundler pry \
&& bundle config --global jobs #{Integer(`sysctl -n hw.ncpu`) - 1}")
# Database
mariadb = prompt "Install MariaDB? (yes/no) "
if mariadb == 'yes' && [email protected]?('mariadb')
run_cmd('brew tap homebrew/services \
&& brew install mariadb \
&& brew services start mariadb')
end
# Devops
devops = prompt "Install devops tools? (yes/no) "
if devops == 'yes'
run_brew('install', [
'ansible',
'aria2',
'aws-shell',
'geoip --with-geoipupdate',
'vegeta',
'speedtest_cli'
])
run_cmd('pip install -U awscli boto s3cmd')
end
latest_git_ssh = prompt "Install latest git and ssh? (yes/no) "
if latest_git_ssh == 'yes'
run_brew('install', [
'git --with-blk-sha1 --with-brewed-curl --with-brewed-openssl --with-persistent-https',
'openssh',
'ssh-copy-id'
])
end
run_cmd('brew cleanup')
if fish != 'yes'
append_to_rc = "
PATH=\"/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/findutils/libexec/gnubin:$PATH\"
MANPATH=\"/usr/local/opt/coreutils/libexec/gnuman:/usr/local/opt/findutils/libexec/gnuman:$MANPATH\"
export NVM_DIR=\"$HOME/.nvm\"
source /usr/local/opt/nvm/nvm.sh"
`touch ~/.zshrc && echo \'#{append_to_rc}\' >> ~/.zshrc`
else
append_to_rc = "
set -gx NVM_DIR /usr/local/opt/nvm/
set -gx PATH /usr/local/opt/coreutils/libexec/gnubin /usr/local/opt/findutils/libexec/gnubin $PATH
set -gx MANPATH /usr/local/opt/coreutils/libexec/gnuman /usr/local/opt/findutils/libexec/gnuman $MANPATH
"
`touch ~/.config/fish/config.fish && echo \'#{append_to_rc}\' >> ~/.config/fish/config.fish`
end