Created
November 14, 2011 01:51
-
-
Save omo/1363059 to your computer and use it in GitHub Desktop.
Open an octopress file in Emacs.
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
;; 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)) |
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 "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