From dd1b2aeb1b444c10aaac5f840c37a3f358d082e1 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Wed, 27 Nov 2013 01:17:03 +0200 Subject: [PATCH] lib/pry/commands/cat.rb: add TAB-completion for $LOAD_PATH (fixes #1020) Note that we want to skip over directories. --- lib/pry/commands/cat.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pry/commands/cat.rb b/lib/pry/commands/cat.rb index a6f96267..8889f547 100644 --- a/lib/pry/commands/cat.rb +++ b/lib/pry/commands/cat.rb @@ -45,7 +45,16 @@ class Pry end def complete(search) - super + Bond::Rc.files(search.split(" ").last || '') + super | Bond::Rc.files(search.split(' ').last || '') | load_path_completions + end + + def load_path_completions + $LOAD_PATH.flat_map do |path| + Dir[path + '/**/*'].map { |f| + next if File.directory?(f) + f.sub(path + '/', '') + } + end end end