Permalink
Browse files

Load rmjunk rules from a file instead of hardcoding them.

  • Loading branch information...
1 parent aa14056 commit 309d4fbeb6aa4f1571493372bcdab547a5d2cc09 @SaberUK committed Dec 15, 2012
Showing with 26 additions and 4 deletions.
  1. +22 −0 _config/rmjunk.yml
  2. +4 −4 bin/rmjunk
View
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+# ==============================================================================
+# SaberUK's Dot Files <https://github.com/saberuk/dotfiles/>
+# ==============================================================================
+# Copyright (C) 2012 Peter "SaberUK" Powell <petpow@saberuk.com>
+# ==============================================================================
+
+remove:
+ - '._*'
+ - '.*_history'
+ - '.*-history'
+ - '*.LSSharedFileList.plist'
+ - '*.rbc'
+ - '.bzr.log'
+ - '.DS_Store'
+ - '.TemporaryItems'
+ - 'desktop.ini'
+ - 'Thumbs.db'
+
+skip:
+ - '.git'
+ - '.svn'
View
@@ -6,17 +6,17 @@
# ==============================================================================
require 'fileutils'
require 'find'
+require 'yaml'
if ARGV.size < 1
puts "Syntax: #{File.basename($PROGRAM_NAME)} <dir> [sim]"
exit 1
else
- JUNK_ITEMS = [ '._*', '.*_history', '*.rbc', '*.LSSharedFileList.plist', '.DS_Store', '.TemporaryItems', 'desktop.ini', 'Thumbs.db' ].freeze
- SKIP_DIRS = [ '.git' ]
+ CONFIG = YAML.load_file(File.expand_path('~/.config/rmjunk.yml')).freeze
Find.find(ARGV[0]).each do |file|
- next if File.directory?(file) && SKIP_DIRS.include?(file)
+ next if File.directory?(file) && CONFIG['skip'].include?(file)
file_path = File.expand_path(file)
file_name = File.basename(file)
- JUNK_ITEMS.each do |junk_item|
+ CONFIG['remove'].each do |junk_item|
if File.fnmatch(junk_item, file_name)
if ARGV.size >= 2 && ARGV[1] == 'sim'
puts "#{file_path} would be deleted!"

0 comments on commit 309d4fb

Please sign in to comment.