forked from rhoml/mydotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
61 lines (55 loc) · 1.21 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
# All credits of this script goes to @arkham
# https://github.com/Arkham/dotfiles/blob/master/Rakefile
task :default => [:backup_dir, :backup, :link]
WHOAMI = ENV['USER']
DOTFILES_DIR = "/Users/#{WHOAMI}/.dotfiles"
BACKUP_DIR = "/Users/#{WHOAMI}/.dotfiles-backup"
DOTFILES = %w(
Brewfile
curlrc
dockerignore
gemrc
gitignore
gitconfig
gitcookies
gitmessage
mrconfig
mrtrust
p10k.zsh
ssh
tmux.conf
vimrc
wgetrc
zprofile
zsh.d
zshrc
)
desc %(Make symlinks of dotfiles)
task :link do
DOTFILES.each do |script|
dotfile = File.join(ENV['HOME'], ".#{script}")
if File.exist? dotfile
warn "~/.#{script} already exists"
else
ln_s File.join(DOTFILES_DIR, ".#{script}"), dotfile
end
end
end
desc %(Backup existing dotfiles)
task :backup do
DOTFILES.each do |script|
dotfile = File.join(ENV['HOME'], ".#{script}")
if File.exist?(dotfile) && !File.symlink?(dotfile)
backup = File.join(BACKUP_DIR, script)
if File.exists? backup
warn "#{BACKUP_DIR}/#{script} already exists"
else
mv dotfile, backup
end
end
end
end
desc %(Create backup dir)
task :backup_dir do
mkdir_p BACKUP_DIR unless File.directory?(BACKUP_DIR)
end