Skip to content

Instantly share code, notes, and snippets.

@nisanthchunduru
Created June 12, 2017 10:36
Show Gist options
  • Save nisanthchunduru/cc859d7fdd9e09473362d9d442f74afd to your computer and use it in GitHub Desktop.
Save nisanthchunduru/cc859d7fdd9e09473362d9d442f74afd to your computer and use it in GitHub Desktop.
Backup dotfiles that RCM already tracks
require "fileutils"
class DotfileInfo
def initialize(dotfile_info_string)
@dotfile_info_string = dotfile_info_string
end
def path
@dotfile_info_string.split(":")[0]
end
def backup_path
@dotfile_info_string.split(":")[1]
end
end
dotfile_info_strings = `lsrc`.split("\n")
dotfile_info_strings.each do |dotfile_info_string|
dotfile_info = DotfileInfo.new(dotfile_info_string)
FileUtils.cp(dotfile_info.path, dotfile_info.backup_path) if File.exist?(dotfile_info.path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment