-
Notifications
You must be signed in to change notification settings - Fork 0
/
dots.rb
executable file
·94 lines (80 loc) · 1.5 KB
/
dots.rb
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
#!/usr/bin/env ruby
require 'fileutils'
######################################
# keep dot directories
SRC_DIR='/home/arch/alan'
THIS_DIR='/home/dots'
DOTDIRS=%w(
.adobe
.cache
.config
.cpan
.fonts
.gconf
.gem
.gtkpod
.m2
.macromedia
.mysql
.shotwell
.ssh
.stardict
.sunpinyin
.vimperator
.mozilla
)
LINK_DIRS=%w(
.aMule
.thunderbird
.vbox
)
######################################
# keep dot files
DOTFILES=%w(
.arcrc
.bash_history
.bash_profile
.fonts.conf
.gemrc
.gitconfig
.goaccessrc
.gtk-bookmarks
.irb_history
.irbrc
.my.cnf
.mysql_history
.tmux.conf
.viminfo
.vim_mru_files
.vimperatorrc
.vimrc
.Xmodmap
)
def main
home_dir = ENV['HOME']
puts DOTFILES.size, DOTFILES[0]
DOTFILES.each do |file|
puts "cp/ln #{file}..."
src = "#{SRC_DIR}/#{file}"
underline = file.sub(/^\./, '_')
dest = "#{home_dir}/#{file}"
FileUtils.cp src, underline
FileUtils.rm dest if FileTest.exists?(dest) || FileTest.symlink?(dest)
FileUtils.ln_s "#{THIS_DIR}/#{underline}", dest
end
DOTDIRS.each do |dir|
puts "cp/ln #{dir}..."
src = "#{SRC_DIR}/#{dir}"
underline = dir.sub(/^\./, '_')
dest = "#{home_dir}/#{dir}"
FileUtils.cp_r src, underline
FileUtils.rm_rf dest if FileTest.directory?(dest)
FileUtils.rm dest if FileTest.exists?(dest) || FileTest.symlink?(dest)
FileUtils.ln_s "#{THIS_DIR}/#{underline}", dest
end
end
main()
######################################
# copy...
# .vim
# .vbox