-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
321 lines (241 loc) · 12 KB
/
setup.py
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python
# -*- coding: utf-8 -*-
import os
import json
import urllib2
import subprocess
name = ''
email = ''
options = { 'developer': '', 'android': '', 'ios': '', 'designer': '', 'web' : '',
'sublime': '', 'vim': '', 'zsh': '',
'animations': '', 'showhiddenfiles': '', 'autoupdate': '', }
# Check if Xcode Command Line Tools are installed
if os.system('xcode-select -p') != 0:
print "Installing Xcode Tools"
os.system('xcode-select --install')
print "**************************************************************"
print "Install the Xcode Command Line Tools and run this script again"
print "**************************************************************"
exit()
# Sudo: Spectacle, ZSH, OSX Settings
print "\n"
print "**************************************************************"
print "Let's set up your Mac toghether! ⬢"
print "**************************************************************"
print "\n"
# Basic Info
while name == '':
name = raw_input("# What's your name?\n").strip()
while email == '' or '@' not in email:
email = raw_input("# What's your email?\n").strip()
# Setup Options
print "What do you want to install?"
while options['designer'] not in ['y', 'n']:
options['designer'] = raw_input("- Designer Tools (%s) " % '|'.join(['y','n']))
while options['developer'] not in ['y', 'n']:
options['developer'] = raw_input("- Developer Tools (%s) " % '|'.join(['y','n']))
if options['developer'] == 'y':
while options['web'] not in ['y', 'n']:
options['web'] = raw_input(" - Web Developer Tools (%s) " % '|'.join(['y','n']))
while options['ios'] not in ['y', 'n']:
options['ios'] = raw_input(" - iOS Tools (%s) " % '|'.join(['y','n']))
while options['android'] not in ['y', 'n']:
options['android'] = raw_input(" - Android Tools (%s) " % '|'.join(['y','n']))
# Other Options
while options['vim'] not in ['y', 'n']:
options['vim'] = raw_input(" - VIM with Awesome VIM (%s) " % '|'.join(['y','n']))
while options['zsh'] not in ['y', 'n']:
options['zsh'] = raw_input(" - Oh My Zsh (%s) " % '|'.join(['y','n']))
while options['animations'] not in ['y', 'n']:
options['animations'] = raw_input("Do you want to accelerate OSX animations? (%s) " % '|'.join(['y','n']))
while options['showhiddenfiles'] not in ['y', 'n']:
options['showhiddenfiles'] = raw_input("Do you want to show hidden files? (%s) " % '|'.join(['y','n']))
while options['autoupdate'] not in ['y', 'n']:
options['autoupdate'] = raw_input("Do you want to update your computer automatically? (Recommended) (%s) " % '|'.join(['y','n']))
def show_notification(text):
os.system('osascript -e \'display notification "'+ text +'" with title "Mac Setup"\' > /dev/null')
print "\n\n"
print "Hi %s!" % name
print "You'll be asked for your password at a few points in the process"
print "*************************************"
print "Setting up your Mac..."
print "*************************************"
# Create a Private Key
if not os.path.isfile(os.path.expanduser("~") + '/.ssh/id_rsa.pub') :
print "Creating your Private Key"
os.system('ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" -C "%s"' % email)
# Set computer name & git info (as done via System Preferences → Sharing)
os.system('sudo scutil --set ComputerName "%s"' % name)
os.system('sudo scutil --set HostName "%s"' % name)
os.system('sudo scutil --set LocalHostName "%s"' % name.replace(' ', '-')) # Doesn't support spaces
os.system('sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "%s"' % name)
os.system('git config --global user.name "%s"' % name)
os.system('git config --global user.email "%s"' % email)
# Install Brew & Brew Cask
print "Installing Brew & Brew Cask"
os.system('touch ~/.bash_profile')
os.system('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
os.system('brew tap caskroom/cask')
os.system('brew tap homebrew/services')
os.system('brew tap caskroom/versions')
os.system('brew tap caskroom/fonts')
os.system('brew update && brew upgrade && brew cleanup && brew cask cleanup')
# Install Languages
print "Installing Git+PHP+Python+Ruby"
os.system('brew install git php node python python3 ruby')
os.system('brew link --overwrite git php node python python3 ruby')
os.system('brew unlink python && brew link --overwrite python') # Fixes an issue with pip
os.system('brew install git-flow git-lfs')
os.system('git lfs install')
print "Installing Useful Stuff"
os.system('brew install graphicsmagick curl wget sqlite libpng libxml2 openssl')
os.system('brew install bat tldr tree')
print "Installing Command Line Tools"
os.system('npm install -g yo gulp-cli node-gyp serve ndb')
print "Installing Fonts"
os.system('brew tap homebrew/cask-fonts')
os.system('brew cask install font-comfortaa font-open-sans font-open-sans-condensed font-roboto font-roboto-mono font-roboto-condensed font-roboto-slab font-lato font-noto-sans font-noto-serif')
os.system('brew cask install font-source-sans-pro font-source-serif-pro font-ubuntu font-pt-mono font-pt-sans font-pt-serif font-fira-mono font-fira-code font-fira-sans font-source-code-pro font-montserrat')
print "Installing Essential Apps"
os.system('brew cask install hyper spectacle the-unarchiver')
os.system('brew cask install google-chrome firefox min github visual-studio-code')
os.system('brew cask install atom skype spotify slack vlc macdown notion')
print "Installing Hyper Plugins"
os.system('hyper i hypercwd')
os.system('hyper i hyperborder')
os.system('hyper i hyperterm-tab-icons')
os.system('hyper i hyper-blink')
os.system('hyper i hyperterm-cursor')
# Appropriate Software
if options['developer'] == 'y':
print "Installing Developer Tools"
os.system('brew cask install docker ngrok sequel-pro tunnelblick insomnia')
os.system('curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash')
if options['android'] == 'y':
print "Installing Android Tools"
show_notification("We need your password")
os.system('brew tap caskroom/versions')
os.system('brew cask install caskroom/versions/java8')
os.system('brew cask install android-studio')
os.system('brew install android-platform-tools')
if options['ios'] == 'y':
print "Installing iOS Tools"
show_notification("We need your password")
os.system('sudo gem install cocoapods')
show_notification("We need your password")
os.system('sudo gem install fastlane --verbose')
if options['web'] == 'y':
print "Installing Web Developer Tools"
os.system('brew cask install imageoptim imagealpha xnconvert')
os.system('brew install mysql mcrypt composer')
os.system('brew services start mysql')
os.system('composer global require laravel/installer')
os.system('composer global require laravel/valet')
os.system('valet install')
os.system('valet start')
show_notification("We need your password")
os.system('sudo gem install rails -v 6.0.0')
os.system('pip3 install Django')
if not os.path.isdir('/usr/local/bin') :
os.system('sudo mkdir -p /usr/local/bin')
if options['designer'] == 'y':
print "Installing Designer Tools"
os.system('brew cask install invisionsync skala-preview')
os.system('brew cask install adapter handbrake')
os.system('brew cask install origami-studio')
if options['vim'] == 'y':
print "Installing VIM + Awesome VIM"
os.system('brew install vim --with-override-system-vi')
os.system('git clone https://github.com/amix/vimrc.git ~/.vim_runtime')
os.system('sh ~/.vim_runtime/install_awesome_vimrc.sh')
# Oh-My-ZSH
if options['zsh'] == 'y':
print "Installing Oh-My-Zsh"
show_notification("We need your password")
# Setup Adapted from https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
if os.system('test -n "$ZSH"') != 0:
os.system('export ZSH=~/.oh-my-zsh')
if os.system('test -n "$ZSH_CUSTOM"') != 0:
os.system('export ZSH_CUSTOM=~/.oh-my-zsh/custom')
if os.system('test -d "$ZSH"') != 0:
os.system('umask g-w,o-w && git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH')
if os.system('test -f ~/.zshrc') != 0:
os.system('cp $ZSH/templates/zshrc.zsh-template ~/.zshrc')
# If the user has the default .zshrc tune it a bit
if (subprocess.call(['bash', '-c', 'diff <(tail -n +6 ~/.zshrc) <(tail -n +6 ~/.oh-my-zsh/templates/zshrc.zsh-template) > /dev/null']) == 0):
# Agnoster Theme
# os.system('sed -i -e \'s/robbyrussell/agnoster/g\' ~/.zshrc &> /dev/null')
# Plugins
# os.system('sed -i -e \'s/plugins=(git)/plugins=(git brew sublime node npm docker zsh-autosuggestions zsh-syntax-highlighting colored-man-pages copydir copyfile extract)/g\' ~/.zshrc &> /dev/null')
# Pure Theme for OMZ
os.system('npm install -g pure-prompt')
os.system('echo "autoload -U promptinit; promptinit" >> ~/.zshrc')
os.system('echo "prompt pure" >> ~/.zshrc')
# Customizations
os.system('echo "alias dog=\'bat\'" >> ~/.zshrc')
# Don't show the user in the prompt
os.system('echo "DEFAULT_USER=\`whoami\`" >> ~/.zshrc')
os.system('echo "export NVM_DIR=\"\$HOME/.nvm\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm" >> ~/.zshrc')
os.system('source ~/.zshrc')
print "Change Hyper shell configuration to: '/bin/zsh'"
# Remove the 'last login' message
os.system('touch ~/.hushlogin')
# Random OSX Settings
print "Tweaking OSX Settings"
if options['showhiddenfiles'] == 'y':
# Finder: show hidden files by default
os.system('defaults write com.apple.finder AppleShowAllFiles -bool true')
# Finder: show all filename extensions
os.system('defaults write NSGlobalDomain AppleShowAllExtensions -bool true')
# Finder: allow text selection in Quick Look
os.system('defaults write com.apple.finder QLEnableTextSelection -bool true')
# Check for software updates daily
os.system('defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1')
# Disable auto-correct
#os.system('defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false')
# Require password immediately after sleep or screen saver begins
os.system('defaults write com.apple.screensaver askForPassword -int 1')
os.system('defaults write com.apple.screensaver askForPasswordDelay -int 0')
# Show the ~/Library folder
os.system('chflags nohidden ~/Library')
# Don’t automatically rearrange Spaces based on most recent use
os.system('defaults write com.apple.dock mru-spaces -bool false')
# Prevent Time Machine from prompting to use new hard drives as backup volume
os.system('defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true')
if options['animations'] == 'y':
print "Tweaking System Animations"
os.system('defaults write NSGlobalDomain NSWindowResizeTime -float 0.1')
os.system('defaults write com.apple.dock expose-animation-duration -float 0.15')
os.system('defaults write com.apple.dock autohide-delay -float 0')
os.system('defaults write com.apple.dock autohide-time-modifier -float 0.3')
os.system('defaults write NSGlobalDomain com.apple.springing.delay -float 0.5')
os.system('killall Dock')
if options['autoupdate'] == 'y':
print "Enabling Automatic Brew Updates & Upgrades"
os.system('brew tap domt4/autoupdate')
os.system('brew autoupdate --start --upgrade')
# Open Spectacle (Needs to be enabled manually)
# os.system('open -a "Spectacle"')
# Clean Up
os.system('brew cleanup')
# # Mute startup sound
# show_notification("We need your password")
# os.system('sudo nvram SystemAudioVolume=%00')
print ""
print ""
print "*************************************"
print "Enabling FileVault"
os.system('sudo fdesetup enable')
print ""
print "*************************************"
print "Your SSH Public Key is:"
with open(os.path.expanduser("~") + '/.ssh/id_rsa.pub', 'r') as f:
print f.read()
print ""
print "*************************************"
print "Remember to restart your Mac"
print "*************************************"
show_notification("All done! Enjoy your new macOS!")
# Change the shell if necessary
if options['zsh'] == 'y':
os.system('chsh -s /bin/zsh &> /dev/null')