Created
January 4, 2013 09:50
-
-
Save anonymous/4451316 to your computer and use it in GitHub Desktop.
save clipboard history
This file contains 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' | |
Dir.chdir | |
Dir.chdir(FileUtils.mkdir_p('cblog').last) | |
last_string = nil | |
loop do | |
sleep 1 | |
string = IO.popen('pbpaste', 'r+') {|io| io.read } | |
next if string.nil? || string.empty? || string == last_string | |
filename = Time.now.strftime('%Y%m%d_%H%M%S_') | |
filename << string[0,8].gsub(/\W/, '_') | |
filename << '.txt' | |
File.open(filename, 'w') {|f| f.write(string) } | |
last_string = string | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment