-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
55 lines (43 loc) · 1.11 KB
/
Rakefile
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
require 'yaml'
require 'rbconfig'
CONFIG_FILE = "config.yml"
# utility: loads config.yml
task :load_config do
unless File.exist?(CONFIG_FILE)
puts "Please create config.yml with copying config.yml.example"
exit 1
end
@config = YAML.load_file(CONFIG_FILE)
@dotfiles = @config["common"]
# platform specifics
case RbConfig::CONFIG["host_os"]
when /^darwin/
@dotfiles += @config["darwin"]
when /^linux/
@dotfiles += @config["linux"]
end
end
desc "bootstrap the dotfiles to $HOME"
task bootstrap: :load_config do
cd ENV["HOME"] do
@dotfiles.each do |dotfile|
unless File.exist?(dotfile)
directory = File.dirname(dotfile)
mkdir_p directory unless Dir.exist?(directory)
ln_s File.join(__dir__, dotfile), dotfile
end
end
end
end
desc "remove the dotfiles from $HOME"
task clean: :load_config do
cd ENV["HOME"] do
@dotfiles.each do |dotfile|
rm_f dotfile
end
end
end
desc "link some useful binaries into PATH locations"
task :mklink do
ln_s "/usr/local/share/git-core/contrib/diff-highlight/diff-highlight", "/usr/local/bin"
end