Skip to content

Instantly share code, notes, and snippets.

@omo
Created November 8, 2011 11:53
Show Gist options
  • Save omo/1347579 to your computer and use it in GitHub Desktop.
Save omo/1347579 to your computer and use it in GitHub Desktop.
open today's journal. used from emacs.
#!/usr/bin/env ruby
require "date"
Dir::chdir(File::join(ENV["HOME"], "work/octopress"))
if (ARGV[0] == "pub")
system("bash -l -c 'rvm use 1.9.2 && rake generate deploy'")
exit
end
pattern = Date.today.strftime("source/_posts/%Y-%m-%d-*.markdown")
existing = Dir.glob(pattern)
if existing.empty?
IO.popen("bash -l", "r+") do |io|
io.write("rvm use 1.9.2\n")
io.write("rake new_post['Today']\n")
io.write("exit\n")
io.readlines
end
existing = Dir.glob(pattern)
end
print File::expand_path(existing[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment