-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.rb
executable file
·60 lines (47 loc) · 1 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
#!/usr/bin/env ruby
require 'getoptlong'
class DotfileInstaller
do_it = false
force = false
def initialize
opts = GetoptLong.new(
['--do-it', GetoptLong::NO_ARGUMENT],
['--force', GetoptLong::NO_ARGUMENT]
)
opts.each do |opt, arg|
case opt
when '--do-it'
@do_it = true
when '--force'
@force = true
end
end
end
def execute
%w(
ctags editorconfig gitconfig gitignore gvimrc gemrc tmux.conf vimrc zshrc
).each do |resource|
copy resource
end
end
private
def copy(resource)
options = '-s'
target = File.expand_path("~/.#{resource}")
source = File.expand_path("~/.dotfiles/#{resource}")
if File.exists?(target)
if @force
options << 'f'
else
puts "exists #{target}"
return
end
end
do_command "ln #{options} #{source} #{target}"
end
def do_command(command)
puts command
system command if @do_it
end
end
DotfileInstaller.new.execute