Skip to content

Instantly share code, notes, and snippets.

@omo
Created November 14, 2011 01:51
Show Gist options
  • Save omo/1363059 to your computer and use it in GitHub Desktop.
Save omo/1363059 to your computer and use it in GitHub Desktop.
Open an octopress file in Emacs.
;; on setup
(setq tj-name "/Users/morrita/work/trivials/tj.rb")
;;
;; Create and open the journal file
;;
(when (bound-and-true-p tj-name)
(defun my-open-tj (given-title)
(interactive "MTitle: ")
(let ((welcome-page
(find-file-noselect
(shell-command-to-string
(concat tj-name
" "
(if (string= given-title "")
"today"
given-title))))))
(switch-to-buffer welcome-page)))
(define-key ctl-x-map "J" 'my-open-tj))
#!/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
title = ARGV[0]
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['" + title + "']\n")
io.write("exit\n")
io.readlines
end
existing = Dir.glob(pattern)
end
print File::expand_path(existing[-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment