-
-
Save nuclearsandwich/4371592 to your computer and use it in GitHub Desktop.
change tabs to two spaces. part deux
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 | |
# Places the clipboard contents into a new temp text | |
# file and opens the text file in the default text editor | |
require 'ftools' | |
# find an unused file name | |
a = 1 | |
folder = File.expand_path "~/Documents/texts/temp" | |
File.makedirs folder unless File.exist? folder | |
begin | |
file = "%s/tmp%04d.txt" % [folder, a] | |
a += 1 | |
end while File.exist? file | |
# obtain clipboard contents | |
clip = IO.popen('pbpaste', 'r+').read | |
# write contents to a file | |
File.open(file, 'w') {|f| f.write(clip) } | |
# let the user know what the file name is | |
puts file | |
# open the file in default text editor | |
system("open", file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment