-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.rb
110 lines (90 loc) · 2.94 KB
/
bootstrap.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
#!/usr/bin/env ruby
require 'fileutils'
class Bootstrap
class << self
def dotfiles
['gemrc', 'gitconfig', 'gitignore_global', 'irbrc', 'pryrc', 'railsrc', 'zshrc', 'ember-cli', 'gitattributes']
end
def symlink_dotfiles!
dotfiles.each do | path |
repofile = File.basename(path)
hostfile = "#{Dir.home}/.#{repofile}"
# remove the current file if it exists
FileUtils.rm_f hostfile if file_exists? hostfile
# symlink the file checked in git to the home path
FileUtils.ln_sf File.absolute_path(path), File.absolute_path(hostfile)
print_link File.basename(path), File.absolute_path(hostfile)
end
end
def install_fonts!
Dir.glob 'fonts/*.otf' do | repofile |
hostfile = "/Library/#{repofile}"
unless file_exists? hostfile
FileUtils.cp repofile, hostfile
end
end
end
def disable_chrome_swiping!
`defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE`
end
def copy_iterm_profile!
prefs = "com.googlecode.iterm2.plist"
repofile = "iTerm/#{prefs}"
hostfile = "#{Dir.home}/Library/Preferences/#{prefs}"
FileUtils.rm_f hostfile if file_exists? hostfile
FileUtils.cp repofile, hostfile
print_link prefs, hostfile
end
def symlink_sublime_directory!
symlink_folder(
"Sublime/Packages/User",
"#{Dir.home}/Library/Application\ Support/Sublime\ Text\ 3/Packages/User"
)
# Set up /bin/subl
FileUtils.ln_sf "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl", "/usr/local/bin/subl"
end
def symlink_alfred!
symlink_folder(
"Alfred",
"#{Dir.home}/Library/Application\ Support/Alfred"
)
end
def symlink_oh_my_zsh!
symlink_folder(
"oh-my-zsh/custom/plugins",
"#{Dir.home}/.oh-my-zsh/custom/plugins"
)
end
def symlink_extras!
symlink_folder("IMDB\ this.workflow", "#{Dir.home}/Library/Services/IMDB\ this.workflow")
symlink_folder("HexColorPicker.colorPicker", "#{Dir.home}/Library/ColorPickers/HexColorPicker.colorPicker")
end
def run!
symlink_dotfiles!
disable_chrome_swiping!
symlink_sublime_directory!
symlink_alfred!
symlink_oh_my_zsh!
symlink_extras!
copy_iterm_profile!
install_fonts!
printf 'Now update ~/.gitconfig to refer to your GitHub username instead of mine :)'
end
private
def print_link(src, dest)
printf " %15s -> %s\n", src, dest.gsub!("/Users/#{username}", '~')
end
def username
`whoami`
end
def file_exists? (file)
File.exists?(file) || File.symlink?(file)
end
def symlink_folder(source, destination)
FileUtils.rm_f destination if file_exists? destination
FileUtils.ln_sf File.absolute_path(source), destination
print_link source, destination
end
end
end
Bootstrap.run!