Skip to content

Instantly share code, notes, and snippets.

@knoopx
Created June 14, 2012 22:04
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save knoopx/2933250 to your computer and use it in GitHub Desktop.
Save knoopx/2933250 to your computer and use it in GitHub Desktop.
Gitshots Post-Commit Hook
#!/usr/bin/env ruby
# Requires imagesnap from https://github.com/alexwilliamsca/imagesnap (brew install imagesnap)
# To assemble the video use http://www.dayofthenewdan.com/projects/tlassemble
file="~/.gitshots/#{Time.now.to_i}.jpg"
puts "Taking capture into #{file}!"
system "imagesnap -q -w 3 #{file}"
exit 0
@zacstewart
Copy link

Fore a pure shell implementation:

#!/bin/sh
imagesnap -q $HOME/.gitshots/$(date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s").jpg &

This has the advantage of being run in the background, so you don't have to wait for the camera to finish after each commit.

@glukki
Copy link

glukki commented May 10, 2013

Or you could simplify it like this ;)

#!/bin/sh
imagesnap -q $HOME/.gitshots/$(date "+%s").jpg &

Because on my system date -j -f "%a %b %d %T %Z %Y" "date" "+%s" fails to convert date

@najamkhn
Copy link

For Linux/Ubuntu you can use streamer..

file="~/.gitshots/#{Time.now.to_i}.jpg"
puts "Taking capture into #{file}!"
system "streamer -f jpeg #{file}"
exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment