I would like to know to how to do in Ruby what I can do with system(\"clear\")
in C.
I wrote a program like
puts \"amit\"
system(\"clear\")
If you use Pry, It's very simple
Just .clear
This should cover windows and OSX/Linux terminals.
def method_name
puts "amit"
if RUBY_PLATFORM =~ /win32|win64|\.NET|windows|cygwin|mingw32/i
system('cls')
else
system('clear')
end
end
method_name
Edit: (rereading your question I realize this is not what you are after. I thought you were referring to the IRB. I will leave this here and not delete it as I feel it is can be very useful information)
Ultimately it depends what system you are on.
ctrl+l (<- that is a lower case L) will clear the terminal ( cmd+K on a mac I believe)
this also works in the regular terminal, or the python interprator, or mysql, etc
there are a fair amount of other shortcuts you may like to familiarize yourself with. i found this after a quick google search:
CTRL-l - Clears the screen and places the command prompt at the top of the page.
CTRL-r - Starts a search against the command history. Start by typing in what you want to search by then press CTRL-r to see the matches.
CTRL-c - Kills the current running foreground program.
CTRL-z - Stop/sleep the current running foreground program.
CTRL-s - Stops the output to the screen.
CTRL-q - Allows output to the screen.
CTRL-a - Moves the cursor the start of the line
CTRL-e - Moves the cursor to the end of the line
CTRL-f - Moves the cursor 1 character forward
CTRL-b - Moves the cursor 1 character backward
not mentioned on that list is that
Alt-F moves the curosor one word forward
Alt- B moves the cursor one word back