Autoload $HOME/.pry/commands. #761

ghost opened this Issue Nov 26, 2012 · 8 comments

3 participants


It'd be really cool if Pry could autoload all *.rb files kept in $HOME/.pry/commands. Right now I have a bunch of commands in my .pryrc but I'd like to map one command to one file, and Pry could assist me by autoloading those commands for me. I think as people customize Pry they'll pick up custom commands and having ~/.pry/commands be auto-loaded should make that experience nicer.


If I didn't miss anything from your question, the solution is straight-forward:


# Hi! I am .pryrc and I can run Ruby snippets!

load "~/file1.rb"
load "~/file2.rb"

puts "Hola..."

And write the individual commands in file1.rb and file2.rb and so on..


Or even:


Dir[File.expand_path("~/.pry/commands/*.rb")].each do |file|
  load file

@richo That works but I think I'd prefer the support to be implemented inside Pry itself.


@kgrz I just saw your comment. Yeah, your suggestion works but it is nowhere near what I want. I want support from Pry and for it to be common for people to use ~/.pry/commands without any additional custom code.

pry member

I think it would make more sense to me if pry just autoloaded any ruby files in ~/.pry and subdirectories. I'm still not sure I like that idea, but special-casing just one subdirectory seems weirdly specific.


@rf- I don't think it is that unusual, though. Doesn't vim do this already? ($HOME/.vim/plugin)


vim has other directories it loads as well, I can't remember those, but I don't think it adds anything & everything that has a '.vim' suffix.

@rf- rf- added the feature label Apr 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment