-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
74 lines (67 loc) · 1.67 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
# 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"
DEV_DIR="/Users/#{WHOAMI}/Development"
REPOSITORIES_DIR="#{DEV_DIR}/repositories"
WORK_DIR="#{REPOSITORIES_DIR}/work"
PERSONAL_DIR="#{REPOSITORIES_DIR}/personal"
DOTFILES = %w(
Brewfile
curlrc
dockerignore
gemrc
gitignore
gitconfig
gitcookies
gitmessage
mrconfig
mrtrust
siegerc
spacemacs
ssh
tmux.conf
wgetrc
zprofile
zsh.d
zshrc
hammerspoon
)
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
desc %(Create working directories)
task :working_dir do
mkdir_p DEV_DIR unless File.directory?(DEV_DIR)
mkdir_p REPOSITORIES_DIR unless File.directory?(REPOSITORIES_DIR)
mkdir_p PERSONAL_DIR unless File.directory?(PERSONAL_DIR)
mkdir_p WORK_DIR unless File.directory?(WORK_DIR)
end