Created
June 12, 2017 10:36
-
-
Save nisanthchunduru/cc859d7fdd9e09473362d9d442f74afd to your computer and use it in GitHub Desktop.
Backup dotfiles that RCM already tracks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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