Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do You Clear The IRB Console?

Tags:

ruby

irb

On Mac OS X or Linux you can use Ctrl + L to clear the IRB screen.


Throw this inside %userprofile%\.irbrc and you're good

def cls
  system('cls')
end

From IRB clear screen on windows.


On *nix boxes

`clear`

on Windows

system 'cls' # works
`cls` # does not work

on OSX

system 'clear' # works
`clear` # does not work

Command + K in macOS works great.


On Ubuntu 11.10 system clear will mostly clear the irb window. You get a return => True value printed.

A big mess of ugly text

ruby-1.9.2-p290 :007 > system 'clear'

what ya get:

 => true 
ruby-1.9.2-p290 :007 > 

Just discovered this today: in Pry (an IRB alternative), a line of input that begins with a . will be forwarded to the command shell. Which means on Mac & Linux, we can use:

. clear

And, on Windows (Command Prompt and Windows Terminal), we can use:

. cls

Source: pry.github.io


system 'clear'

Should work for rails 4.0 as well