Module: Hook::PromptSTD
- Included in:
- Prompt
- Defined in:
- lib/hook/prompt.rb
Instance Method Summary collapse
-
#clear_screen(msg = nil) ⇒ Object
Clear the terminal screen.
-
#restore_std ⇒ Object
Restore silenced STDOUT and STDERR.
-
#silence_std(file = '/dev/null') ⇒ Object
Redirect STDOUT and STDERR to /dev/null or file.
Instance Method Details
#clear_screen(msg = nil) ⇒ Object
Clear the terminal screen
8 9 10 11 |
# File 'lib/hook/prompt.rb', line 8 def clear_screen(msg = nil) puts "\e[H\e[2J" if $stdout.tty? puts msg if msg.good? end |
#restore_std ⇒ Object
Restore silenced STDOUT and STDERR
26 27 28 29 |
# File 'lib/hook/prompt.rb', line 26 def restore_std $stdout = STDOUT $stderr = STDERR end |
#silence_std(file = '/dev/null') ⇒ Object
Redirect STDOUT and STDERR to /dev/null or file
18 19 20 21 |
# File 'lib/hook/prompt.rb', line 18 def silence_std(file = '/dev/null') $stdout = File.new(file, 'w') $stderr = File.new(file, 'w') end |