Created
April 24, 2018 00:30
-
-
Save JeffCohen/008e4f75016faa6a1b05c859a4b6b21b to your computer and use it in GitHub Desktop.
Simple directory watcher
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
# To use this script: | |
# gem install listen | |
# gem install colorize | |
# | |
# then | |
# | |
# ruby watch.rb [path] | |
# | |
# [path] defaults to ".git" | |
# | |
require 'listen' | |
require 'colorize' | |
folder = ARGV.first || '.git' | |
listener = Listen.to(folder, relative: true) do |modified, added, removed| | |
puts "Added : #{added.join("\n ")}".colorize(:green) if added.any? | |
puts "Modified: #{modified.join("\n ")}".colorize(:yellow) if modified.any? | |
puts "Removed : #{removed.join("\n ")}".colorize(:red) if removed.any? | |
puts | |
end | |
puts "Watching #{folder}" | |
puts "Press CTRL-C to stop.\n" | |
listener.start | |
sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment