Skip to content

Instantly share code, notes, and snippets.

@markbates
Created August 22, 2011 18:53
Show Gist options
  • Save markbates/1163187 to your computer and use it in GitHub Desktop.
Save markbates/1163187 to your computer and use it in GitHub Desktop.
Launch TextMate with Pry (.pryrc)
require 'digest/md5'
require 'fileutils'
Pry.config.commands.command "mate" do
FileUtils.mkdir_p(File.expand_path('~/tmp/pry'))
file = File.expand_path("~/tmp/pry/_#{Digest::MD5.hexdigest(FileUtils.pwd).to_s}.rb")
system "mate -w #{file}"
Object.class_eval(`cat #{file}`)
end
@banister
Copy link

You should use Pry's editor integration to accomplish this:

In your .pryrc:

Pry.config.editor = "mate -w"

And then in the pry session itself to open a temp file and eval the contents on exit:

pry(main)> edit -t
pry(main)> # code will be eval'd here

See more on the edit command here: https://github.com/pry/pry/wiki/Editor-integration#wiki-Edit_command

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