forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
52 lines (41 loc) · 2.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
# ███████ ██ ████ ██ ██
# ░██░░░░██ ░██ ░██░ ░░ ░██
# ░██ ░██ ██████ ░██ ██ █████ ██████ ██ ░██ █████
# ░███████ ░░░░░░██ ░██ ██ ██░░░██░░░██░ ░██ ░██ ██░░░██
# ░██░░░██ ███████ ░████ ░███████ ░██ ░██ ░██░███████
# ░██ ░░██ ██░░░░██ ░██░██ ░██░░░░ ░██ ░██ ░██░██░░░░
# ░██ ░░██░░████████░██░░██░░██████ ░██ ░██ ███░░██████
# ░░ ░░ ░░░░░░░░ ░░ ░░ ░░░░░░ ░░ ░░ ░░░ ░░░░░░
require 'rake'
require 'fileutils'
# These are all the files we want to symlink to ~
FILES = '.gitconfig .hushlogin .vimrc .zshrc .zlogin .p10k.zsh .inputrc .screenrc .vim .curlrc .editorconfig'
task :default => 'install'
desc "Hook our dotfiles into system-standard positions."
task :install do
FILES.split.each do |file|
symlink_file( file )
end
end
# Run as rake setup_file[file_name]
# Zsh will be kind of weird with the brackets, so do this:
# rake 'setup_file[.my_dot_file]'
# unless you add 'unsetopt nomatch' to .zshrc, then you're good to go without the quotes
# symlink multiple files at once
# rake setup_file['.maid .vimrc .hushlogin']
desc "Symlink arbitrary files."
task :setup_file, [:file ] do |t, file|
"#{file[:file]}".split.each do |single_file|
symlink_file( single_file )
end
end
def symlink_file( file )
source = "#{ENV["PWD"]}/#{file}"
target = "#{ENV["HOME"]}/#{file}"
puts "Source: #{source}"
puts "Target: #{target}"
if File.exists?(target) || File.symlink?(target)
puts "[Overwriting] #{target}..."
end
`ln -nfs "#{source}" "#{target}" `
end