/
Rakefile
124 lines (113 loc) · 2.82 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
require 'rake'
require 'erb'
require 'fileutils'
require 'pathname'
include FileUtils
desc "Install into the users home"
task :install do
Dir['*'].each do |file|
case file
when 'Rakefile', 'README', 'README.markdown'
next
when 'xprofile', 'Xdefaults', 'xmodmap'
link_file file, home_slash(".#{file}") if `uname -s`.include? 'Linux'
when 'bin'
unless File.directory? home_slash('bin')
mkdir home_slash('bin'), :verbose => false
end
Dir['bin/*'].each do |bin_file|
link_file bin_file, home_slash(bin_file)
end
else
link_file file, home_slash(".#{file}")
end
end
end
desc "Installs the stuff in homebrew I need"
task :homebrew do
formulas = %w(
ack
figlet
htop
macvim
midnight-commander
tmux
mercurial
tree
vim
watch
wget
zsh
zsh-lovers
navi
cheat
)
exec "brew", "install", *formulas
end
namespace :link do
desc 'Link cheats'
task :cheats do
personal_cheatsheets = home_slash('.config/cheat/cheatsheets/personal')
rmdir personal_cheatsheets if personal_cheatsheets.exist? && personal_cheatsheets.directory? && !personal_cheatsheets.symlink?
rm personal_cheatsheets if personal_cheatsheets.symlink?
ln_s dotfiles_slash('knowledge/cheat'), home_slash('.config/cheat/cheatsheets/personal')
end
end
namespace :perl do
desc 'Install the various perl dependencies'
task :deps do
dependencies = [
'--force Alien::libtickit',
'Tickit',
'Tickit::Widgets',
'Tickit::Widget::ScrollBox',
'utf8::all',
'lib::relative',
'IPC::System::Simple',
'Graphics::Color',
'Term::ReadLine',
'File::Path::Expand',
'Array::Utils',
]
dependencies.each do |line|
system "cpanm install #{line}" or raise 'failed'
end
end
end
def home() ENV['HOME'] end
def home_slash(name) Pathname(home).join(name) end
def dotfiles_slash(name) Pathname(__FILE__).dirname.join(name) end
def link_file(source, target)
action = if File.symlink?(target)
if $replace_all
:overwrite
else
print "Overwrite #{target}? [yNqa] "
case $stdin.gets.chomp
when 'a' then ($replace_all = true) and :overwrite
when 'y' then :overwrite
when 'q' then exit
else :skip
end
end
else
:link
end
if [:link, :overwrite].include? action
if action == :overwrite
puts "Overwriting #{target}"
rm target, :verbose => false
end
ln_s File.join(Dir.pwd, source), target, :verbose => true
elsif action == :skip
puts "skipping #{target}"
end
end
def each_bundle
bundles = `git submodule --quiet foreach 'echo $path'`.map { |line| line.chomp }
bundles.each do |bundle_path|
cd bundle_path, :verbose => false do
yield bundle_path
end
end
end