diff --git a/lib/pry/repl.rb b/lib/pry/repl.rb index 9fa67303..54ccebb0 100644 --- a/lib/pry/repl.rb +++ b/lib/pry/repl.rb @@ -26,10 +26,6 @@ class Pry if options[:target] @pry.push_binding options[:target] end - - if readline_available? && piping? - Readline.output = File.open('/dev/tty', 'w') - end end # Start the read-eval-print loop. @@ -184,6 +180,7 @@ class Pry end if readline_available? + set_readline_output input_readline(current_prompt, false) # false since we'll add it manually elsif coolline_available? input_readline(current_prompt) @@ -222,5 +219,11 @@ class Pry def piping? !$stdout.tty? && $stdin.tty? && !Pry::Helpers::BaseHelpers.windows? end + + def set_readline_output + @readline_output ||= if piping? + Readline.output = File.open('/dev/tty', 'w') + end + end end end