Created
March 27, 2012 18:56
-
-
Save imathis/2219214 to your computer and use it in GitHub Desktop.
Edit Octopress post
This file contains hidden or 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
| desc "Edit a post (defaults to most recent)" | |
| task :edit_post, :title do |t, args| | |
| args.with_defaults(:title => false) | |
| posts = Dir.glob("#{source_dir}/#{posts_dir}/*.*") | |
| post = (args.title) ? post = posts.keep_if {|post| post =~ /#{args.title}/}.last : posts.last | |
| if post | |
| puts "Opening #{post} with #{editor}..." | |
| system "#{ENV['EDITOR']} #{post} &" | |
| else | |
| puts "No posts were found with \"#{args.title}\" in the title." | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pesonally I added a task to my Rakefile:
You could replace
emacsclient -nwith an editor variable at the top of theRakefile(likessh_userordeploy_branch). Also adding the globbing as a default if there is noargs.filenamewould be easy, but personally I modifiednew_postand addedRake::Task["edit"].invoke(filename).