Dan Zwell
4/26/2007 7:30:00 AM
Christian,
The following is a hack: I checked, and on my system, "clear" sends the
following control characters to the screen: ^[[H^[[2J
This will only work on unix, and I'm not sure whether it works on all
terminals, but
puts "\e[H\e[2J"
clears the screen. You might want to use "if $stdout.isatty" so that you
don't get control characters in an output file...
Note that this is pretty much exactly the same thing as system("clear").
If that's not good enough, you probably want to look at terminal
libraries--I think ruby-termios might be useful, but I have no
experience with it.
Dan
Christian wrote:
> Is there a way to clear the terminal screen by using Ruby directly?
> Instead of using system("clear").
>
> Cheers
> Christian
>
>
>