-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
50 lines (43 loc) · 1.24 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
CWD=File.expand_path(File.dirname(__FILE__))
desc "Handling initial setup and linking"
task :init do
puts "pulling submodules"
system "cd #{CWD} && git submodule update --init"
replace_files
setperms
end
desc "Update dotfiles to most recent version"
task :update do
puts "pulling latest from repo"
system "cd #{CWD} && git pull origin master"
system "cd #{CWD} && git submodule foreach git pull origin master"
replace_files
setperms
end
desc "Set permissions - take away perms from group and other"
task :setperms do
setperms
end
def replace_files
files = [ '.bashrc',
'.bash_profile',
'.vim',
'.vimrc',
'.gvimrc',
]
files.each do |file|
system "rm -rf #{ENV['HOME']}/#{file}"
end
link_file("#{CWD}/bash/_bashrc", "#{ENV['HOME']}/.bashrc")
link_file("#{CWD}/bash/_bash_profile", "#{ENV['HOME']}/.bash_profile")
link_file("#{CWD}/vim/_vimrc", "#{ENV['HOME']}/.vimrc")
link_file("#{CWD}/vim/_gvimrc", "#{ENV['HOME']}/.gvimrc")
link_file("#{CWD}/vim", "#{ENV['HOME']}/.vim")
link_file("#{CWD}/_config/awesome", "#{ENV['HOME']}/.config/awesome")
end
def link_file(src, target)
system "ln -fs #{src} #{target}"
end
def setperms
system "chmod -R g-rwx,o-rwx #{CWD}"
end