Skip to content

Instantly share code, notes, and snippets.

@afcapel
Created February 14, 2020 03:00
Show Gist options
  • Save afcapel/6c02c353dd4a9f2ad5bd3debf4ec32a7 to your computer and use it in GitHub Desktop.
Save afcapel/6c02c353dd4a9f2ad5bd3debf4ec32a7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby --disable-gems
require "date"
require "fileutils"
JOURNAL_DIR = File.expand_path("~/textos/diario")
now = DateTime.now
date = now.strftime("%F")
entry = "#{JOURNAL_DIR}/#{date}.md"
new_entry = !File.exist?(entry)
open(entry, "a") do |f|
if new_entry
f << "# #{now.strftime("%A %d %B %Y %H:%M")}\n\n"
else
f << "\n\n"
f << "# #{now.strftime("%H:%M")}\n\n"
end
end
`open #{entry}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment