-
Notifications
You must be signed in to change notification settings - Fork 91
/
config.sh
321 lines (277 loc) · 9.4 KB
/
config.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
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
#!/usr/bin/env bash
# Credit to https://github.com/mathiasbynens/dotfiles for macOS customization
# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
#
# Color key
#
red=$'\e[1;31m'
green=$'\e[1;32m'
yellow=$'\e[1;33m'
blue=$'\e[1;34m'
magenta=$'\e[1;35m'
cyan=$'\e[1;36m'
end=$'\e[0m'
#
# Prep
#
bin_dir="/usr/local/bin"
work_dir="$HOME/work/"
github_dir="$HOME/github/"
ruby_version="2.5.1"
printf "%s\n======================================================================\n%s" $yellow $end
printf "%s# Loading mdo/config\n%s" $yellow $end
printf "%s======================================================================\n%s" $yellow $end
#
# Copying dotfiles
#
printf "%s\n# Copying dotfiles...\n%s" $yellow $end
dotfiles=( bash_profile gitconfig )
for file in "${dotfiles[@]}"
do
printf "%s - .$file%s"
if [[ ! -e "$HOME/.$file" ]]; then
{
curl https://raw.githubusercontent.com/mdo/config/master/.$file > $HOME/.$file
} &> /dev/null
printf "%s - Success!\n%s" $green $end
else
printf "%s - Already present\n%s" $cyan $end
fi
done
#
# Creating directories
#
printf "%s\n# Creating directories...\n%s" $yellow $end
printf "%s - Creating $work_dir...%s"
if [[ ! -e "$work_dir" ]]; then
mkdir $work_dir
printf "%s - Success!\n%s" $green $end
else
printf "%s - Already created\n%s" $cyan $end
fi
printf "%s - Creating $github_dir...%s"
if [[ ! -e "$github_dir" ]]; then
mkdir $github_dir
printf "%s - Success!\n%s" $green $end
else
printf "%s - Already created\n%s" $cyan $end
fi
#
# Cloning repos
#
printf "%s\n# Cloning repositories...\n%s" $yellow $end
cd $github_dir
github_repos=( design brand icons thehub )
for repo in "${github_repos[@]}"
do
printf "%s - github/$repo%s"
if [[ ! -e "$github_dir/$repo" ]]; then
{
git clone https://github.com/github/$repo/ $github_dir/$repo/
} &> /dev/null
printf "%s - Success!\n%s" $green $end
else
printf "%s - Already cloned\n%s" $cyan $end
fi
done
#
# macOS preferences
#
printf "%s\n# Adjusting macOS...\n%s" $yellow $end
{
# Dock
#
# System Preferences > Dock > Automatically hide and show the Dock:
defaults write com.apple.dock autohide -bool true
# System Preferences > Dock > Size:
defaults write com.apple.dock tilesize -int 36
# System Preferences > Mission Control > Automatically rearrange Spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool false
# Clear out the dock of default icons
defaults delete com.apple.dock persistent-apps
defaults delete com.apple.dock persistent-others
# Don’t show recent applications in Dock
defaults write com.apple.dock show-recents -bool false
# Finder
#
# Hide desktop icons
defaults write com.apple.finder CreateDesktop false
# View as columns
defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
# Show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Set sidebar icon size to small
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 1
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Prevent .DS_Store files
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Set Desktop as the default location for new Finder windows
# For other paths, use `PfLo` and `file:///full/path/here/`
defaults write com.apple.finder NewWindowTarget -string "PfDe"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/"
# Save & Print
#
# Expand save and print modals by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
# Set a custom wallpaper image. `DefaultDesktop.jpg` is already a symlink, and
# all wallpapers are in `/Library/Desktop Pictures/`. The default is `Wave.jpg`.
#rm -rf ~/Library/Application Support/Dock/desktoppicture.db
#sudo rm -rf /System/Library/CoreServices/DefaultDesktop.jpg
#sudo ln -s /path/to/your/image /System/Library/CoreServices/DefaultDesktop.jpg
# System Preferences
#
# Disable LCD font smoothing (default 4)
defaults -currentHost write -globalDomain AppleFontSmoothing -int 0
# Hot corner: Bottom right, put display to sleep
defaults write com.apple.dock wvous-br-corner -int 10
defaults write com.apple.dock wvous-br-modifier -int 0
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Enable tap to click for trackpad
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
# Disable keyboard autocorrect
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Disable Dashboard
defaults write com.apple.dashboard mcx-disabled -bool true
# Don’t show Dashboard as a Space
defaults write com.apple.dock dashboard-in-overlay -bool true
# Show battery percentage in menu bar
defaults write com.apple.menuextra.battery ShowPercent -string "YES"
# Safari
#
# Press Tab to highlight each item on a web page
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
# Show the full URL in the address bar (note: this still hides the scheme)
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
# Hide Safari’s bookmarks bar by default
defaults write com.apple.Safari ShowFavoritesBar -bool false
# Enable Safari’s debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
# Enable the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
# Enable “Do Not Track”
defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true
# Terminal
#
# Disable the annoying line marks
defaults write com.apple.Terminal ShowLineMarks -int 0
# Restart Finder and Dock (though many changes need a restart/relog)
killall Finder
killall Dock
} &> /dev/null
printf "%sDone!\n%s" $green $end
#
# Additional dependencies
#
printf "%s\n# Installing additional dependencies...\n%s" $yellow $end
printf "%s\n Homebrew:\n%s" $yellow $end
if [[ ! -e "/usr/local/bin/brew" ]]; then
{
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
} &> /dev/null
printf "%s - Done!\n%s" $green $end
else
printf "%s - Already installed\n%s" $cyan $end
fi
# rbenv
printf "%s - Install rbenv%s"
if [[ ! -e "$HOME/.rbenv" ]]; then
{
brew install rbenv
} &> /dev/null
printf "%s - Done!\n%s" $green $end
else
printf "%s - Already installed\n%s" $cyan $end
fi
# wget (for downloading files from Terminal)
printf "%s - Install wget%s"
if [[ ! -e "$bin_dir/wget" ]]; then
{
brew install wget --with-libressl
} &> /dev/null
printf "%s - Installed!\n%s" $green $end
else
printf "%s - Already installed\n%s" $cyan $end
fi
# install a version of ruby
printf "%s - Install Ruby v$ruby_version%s"
if [[ ! -e "$HOME/.rbenv/versions/$ruby_version/" ]]; then
{
rbenv install $ruby_version
} &> /dev/null
printf "%s - Done!\n%s" $green $end
else
printf "%s - Already installed\n%s" $cyan $end
fi
# set a global version
printf "%s - Set global Ruby version%s"
if [[ ! -e "$HOME/.rbenv/version" ]]; then
{
rbenv install $ruby_version
} &> /dev/null
printf "%s - Done!\n%s" $green $end
else
printf "%s - Already set\n%s" $cyan $end
fi
# node
printf "%s - node%s"
if [[ ! -e "$bin_dir/node" ]]; then
{
brew install node
} &> /dev/null
printf "%s - Installed!\n%s" $green $end
else
printf "%s - Already installed\n%s" $cyan $end
fi
# ruby gems
printf "%s\n Gems:\n%s" $yellow $end
gems=( bundler sass jekyll )
for gem in "${gems[@]}"
do
printf "%s - $gem%s"
if [[ ! -e "$HOME/.rbenv/versions/$ruby_version/bin/$gem" ]]; then
{
gem install $gem
} &> /dev/null
printf "%s - Installed!\n%s" $green $end
else
printf "%s - Already installed\n%s" $cyan $end
fi
done
#
# Atom packages
#
printf "%s\n# Installing Atom packages...\n%s" $yellow $end
atom_packages=( "atom-wrap-in-tag" "selector-to-tag" editorconfig "markdown-writer" "import-sf-mono" "mojave-dark-mode" )
for package in "${atom_packages[@]}"
do
printf "%s - $package%s"
if [[ ! -e "$HOME/.atom/packages/$package" ]]; then
{
apm-beta install $package
} &> /dev/null
printf "%s - Installed!\n%s" $green $end
else
printf "%s - Already installed\n%s" $cyan $end
fi
done
#
# All done!
#
printf "%s\nWoohoo, all done!\n%s" $green $end