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!
And write the individual commands in file1.rb and file2.rb and so on..
Dir[File.expand_path("~/.pry/commands/*.rb")].each do |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.
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.