class Velcro::Symlinker
Symlink files from your dotfiles directory to $HOME
Attributes
dryrun[R]
force[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/velcro/symlinker.rb, line 6 def initialize(options = {}) @dryrun = options[:dryrun] @force = options[:force] end
Public Instance Methods
skip?(target)
click to toggle source
# File lib/velcro/symlinker.rb, line 37 def skip?(target) return false unless File.exist?(target) if force puts "#{target} exists. Forcing removal" return false end puts "#{target} exists. Skipping" true end
symlink!()
click to toggle source
In any subdirectory of your .dotfiles repo, create a file with the .symlink extension which will be stripped when copied to your home diretory with a “.” prefix
ex: ~/.dotfiles/irb/irbrc.symlink -> ~/.irbrc
# File lib/velcro/symlinker.rb, line 17 def symlink! symlinks.each do |symlink| filename = File.basename(symlink, '.symlink') target = File.join(Velcro.home, ".#{filename}") next if skip?(target) puts "Symlinking #{target}" unless dryrun FileUtils.rm_rf(target) if force `ln -s "#{symlink}" "#{target}"` end end end
symlinked?(symlink)
click to toggle source
# File lib/velcro/symlinker.rb, line 31 def symlinked?(symlink) filename = File.basename(symlink, '.symlink') target = File.join(Velcro.home, ".#{filename}") File.exist?(target) end
symlinks()
click to toggle source
# File lib/velcro/symlinker.rb, line 49 def symlinks @symlinks ||= Dir.glob File.join(Velcro.config.dotfiles, '/*/**{.symlink}') end