Created
September 17, 2012 11:48
-
-
Save jowl/3736877 to your computer and use it in GitHub Desktop.
Take photo automatically after every git commit. Run `gitshot --enable` in project base dir to enable.
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
#!/usr/bin/env ruby | |
require 'fileutils' | |
APP = __FILE__.split('/').last | |
pwd = Dir.pwd | |
if ARGV.include? '--enable' | |
post_commit = File.join(pwd,'.git/hooks/post-commit') | |
abort('post commit hook already exist!') if File.exists?(post_commit) | |
File.open(post_commit,'w') do |file| | |
file.puts '#!/bin/sh', __FILE__ | |
file.chmod(0755) | |
end | |
else | |
project = pwd.split('/').last | |
dir = File.join(ENV['HOME'], ".#{APP}", project) | |
FileUtils.mkdir_p dir | |
file_name = File.join(dir, "#{Time.now.to_i}.jpg") | |
system "imagesnap -q #{file_name}" | |
puts "#{APP} saved your picture to #{file_name}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment