-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate-symlinks
More file actions
executable file
·58 lines (52 loc) · 1.46 KB
/
update-symlinks
File metadata and controls
executable file
·58 lines (52 loc) · 1.46 KB
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
#!/usr/bin/env ruby
FILES = {
'aliases' => '.aliases',
'bin' => 'bin',
'zshrc' => '.zshrc',
'default-gems' => '.default-gems',
'default-npm-packages' => '.default-npm-packages',
'gemrc' => '.gemrc',
'gitconfig' => '.gitconfig',
'gitattributes' => '.gitattributes',
'gitignore' => '.gitignore',
'pryrc' => '.pryrc',
'psqlrc' => '.psqlrc',
'railsrc' => '.railsrc',
'rgignore' => '.rgignore',
'ripgreprc' => '.ripgreprc',
'tmux.conf' => '.tmux.conf',
'vimrc' => '.vimrc',
'niri' => '.config/niri',
'nvim' => '.config/nvim',
'waybar' => '.config/waybar',
'ghostty' => '.config/ghostty',
'starship.toml' => '.config/starship.toml',
'swaylock' => '.config/swaylock',
'satty' => '.config/satty',
}.freeze
FILES.each do |file, target|
file_target = File.expand_path("~/#{target}")
if File.symlink?(file_target)
puts "#{file} symlink, skipping" if ARGV.include?('-v')
next
elsif File.exist?(file_target)
puts "#{file} exists in root. [d]elete? [c]opy? [i]gnore?"
prompt = $stdin.gets.chomp
case prompt
when 'd'
system "cp -r #{file_target} #{file_target}.bak"
system "rm -fr #{file_target}"
when 'c'
puts "Copying and removing #{file_target}"
system "cp #{file_target} ."
system "rm -fr #{file_target}"
else
puts 'Ignoring...'
next
end
end
cmd = "ln -sf #{File.expand_path(file)} #{file_target}"
puts cmd
system(cmd)
end
puts 'Finished updating symlinks'