-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.rb
72 lines (63 loc) · 1.27 KB
/
install.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
def main
dotfiles.each { |file| try_linking(file) }
link_bashrc
end
def dotfiles
[
"ackrc",
"agignore",
"authinfo.gpg",
"bashrc",
"bashrc.d",
"bin",
"bundle/config",
"config/ipod-sync.conf",
"config/redshift.conf",
"emacs.d",
"gemrc",
"gitconfig",
"gitignore",
"gitmessage",
"lein/profiles.clj",
"mbsyncrc",
"offlineimaprc",
"offlineimap.py",
"railsrc",
"rubocop.yml",
"rspec",
"tmux.conf",
]
end
def try_linking(file)
if File.exist?(target(file))
puts "skipping #{ target(file) }: #{ skip_reason(target(file)) }"
else
puts "linking #{ target(file) }"
require "fileutils"
FileUtils.mkdir_p(File.dirname(target(file)))
File.symlink(source(file), target(file))
end
end
def source(file)
File.expand_path("~/.dotfiles/#{ file }")
end
def target(file)
File.expand_path("~/.#{ file }")
end
def skip_reason(file)
if File.symlink?(file)
"already linked"
else
"file already exists. delete or move before reinstalling."
end
end
def path_for(file)
File.expand_path(file)
end
def link_bashrc
if File.exist?(path_for("~/.bash_profile"))
File.delete(path_for("~/.bash_profile"))
end
File.symlink(path_for('~/.bashrc'), path_for('~/.bash_profile'))
end
main