tags:

views:

1487

answers:

4

How do you clear the IRB console screen?

+14  A: 

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

John Topley
+7  A: 

throw this inside %userprofile%.irbrc and you're good

def cls
  system('cls')
end

[Source]

Ben Hoffstein
I should clarify that this applies to Windows only.
Ben Hoffstein
You can also do system('clear') on linux and it works fine
Orion Edwards
+4  A: 

on *nix boxes

`clear`

on Windows, I don't think there is a good solution.

EDIT:

Interesting:

system 'cls' #works,
`cls` does not.
AShelly
A: 

The backtick operator captures the output of the command and returns it

s = `cls`
puts s

would work better, I guess.

JesperE
This fails: You get thisirb(main):004:0> `cls`=> "\f"
Orion Edwards
Hm, yes it does. I wonder why.
JesperE