Skip to content

Instantly share code, notes, and snippets.

@bkemper
Created January 20, 2015 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkemper/431a74c123debc3bb928 to your computer and use it in GitHub Desktop.
Save bkemper/431a74c123debc3bb928 to your computer and use it in GitHub Desktop.
Rake task with editor input
task :with_editor do
require "tempfile"
temp_file = Tempfile.new("notes")
unless editor = ENV["EDITOR"]
abort "Please define your editor."
end
# Open editor
system("#{editor} #{temp_file.path}")
#
# Do something with file here
#
# Delete temp file
temp_file.unlink
end
@subelsky
Copy link

looks cool! definitely give it a try -- fyi you can avoid unlink by passing a block to Tempfile#new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment