Skip to content

Instantly share code, notes, and snippets.

@hyuki
Last active March 14, 2020 13:27
Show Gist options
  • Save hyuki/4c38162000fd28f0571fc969d3800e5f to your computer and use it in GitHub Desktop.
Save hyuki/4c38162000fd28f0571fc969d3800e5f to your computer and use it in GitHub Desktop.
gcap.rb - Screen capture
#!/usr/bin/env ruby
# $ grep GCAP_SAVE_DIR ~/.bash_profile
# export GCAP_SAVE_DIR=/Users/YOUR/SAVE/DIR
dir = ENV['GCAP_SAVE_DIR']
n = 0
while
filename = "#{dir}/#{n}.png"
break if not File.exist?(filename)
n += 1
end
# $ man screencapture
system(%Q(screencapture -i #{filename}))
# Add transparent 1 pixel to the png image.
system("transpoint #{filename}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment