¿Cómo Se Limpia La Consola IRB?
¿Cómo se borra la pantalla de la consola IRB?
21 answers
En Mac OS X o Linux se puede utilizar Ctrl + L para borrar el IRB pantalla.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-25 14:07:43
Tira esto dentro {[1] } y eres bueno
def cls
system('cls')
end
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-07-18 16:16:31
On * nix boxes
`clear`
En Windows
system 'cls' # works
`cls` # does not work
En OSX
system 'clear' # works
`clear` # does not work
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-20 21:45:50
En el sistema Ubuntu 11.10 clear
borrará principalmente la ventana irb. Se imprime un valor return => True
.
Un gran lío de texto feo
ruby-1.9.2-p290 :007 > system 'clear'
Lo que obtienes:
=> true
ruby-1.9.2-p290 :007 >
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-06 15:57:00
Mando + K en macOS funciona muy bien.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-28 12:21:32
Para limpiar la pantalla simplemente haga:
puts "\e[H\e[2J"
P.d. Esto fue probado en Linux.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-06 16:20:00
Acaba de descubrir esto hoy: En Pry (una alternativa IRB), una línea de entrada que comienza con un .
será reenviada al shell de comandos. Lo que significa que en mac y Linux, podemos usar:
. clear
Actualización: Desafortunadamente, no parece funcionar en Windows.
Fuente: Pryrepl.org
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-28 10:02:45
puts `clear`
Borra la pantalla y luego devuelve => nil
Probado en Mac OSX 10.6 Terminal e iTerm2.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-04-24 03:06:06
system 'clear'
También debería funcionar para rails 4.0
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-20 09:54:24
En Linux Mint 17 también puede usar Ctrl + Shift + L
O
Ctrl + L para borrar la pantalla IRB.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-21 13:01:17
En Windows, usando Rails 4,
system('cls')
Funcionó para mí
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-16 15:18:32
Los usuarios de Windows simplemente prueban,
system 'cls'
O
system('cls')
Se ve así en la ventana IRB,
irb(main):333:0> system 'cls'
irb(main):007:0> system('cls')
Hizo el truco para mí en ruby 1.9.3. Sin embargo, los siguientes comandos no funcionaron y devolvieron => nil
,
system('clear')
system 'clear'
system `cls` #using the backquotes below ESC Key in windows
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-29 12:22:10
Añádase el siguiente método a ~/.irbrc
:
def clear
conf.return_format = ""
system('clear')
end
Cntrl-L
o Cntrl-K
funciona en la consola normal pero estoy usando tmux y eso ensucia la pantalla dentro de la ventana de tmux.
La conf.return_format = "" quita el nil del valor devuelto.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-07-18 16:20:42
He usado esto para archivos ejecutables:
def clear
system("cls") || system("clear") || puts("\e[H\e[2J")
end
clear
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-11-20 17:30:22
Método:
def clear_screen
if RUBY_PLATFORM =~ /win32|win64|\.NET|windows|cygwin|mingw32/i
system('cls')
else
system('clear')
end
end
O en IRB puedes usar system('clear')
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-09-08 15:08:40
system 'cls'
Funciona para mí en Windows, con Ruby 2.2.0 y rails 4.0
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-09 11:48:12
Toneladas de buenas respuestas aquí, pero a menudo remoto en una caja de Linux con Mintty de windows. Felicitaciones a lo anterior sobre el uso .irbrc, pero se le ocurrió esto:
def cls
puts "\ec\e[3J"
end
def clear
puts "\e[H\e[2Js"
end
Esto le da las opciones tanto para el comportamiento 'clear' de *nix como para el comportamiento 'cls' de Windows, que a menudo encuentro más útil si realmente quiero bombardear el búfer en lugar de simplemente desplazarlo fuera de la vista.
P.d. Una variante similar también funciona .bashrc:
alias cls='echo -e "\ec\e[3J"'
Si alguien pudiera encontrar una manera de mapear realmente que a una pulsación de tecla, me encantaría escucharlo. Realmente me gustaría tener algo similar a cmd-k en osx que funcionara en Mintty.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-21 01:26:39
Vine aquí buscando una manera de restablecer el tty con irb, ya que no estaba imprimiendo nuevas líneas o mostrando lo que escribí de alguna manera, solo algo de salida.
1.9.3-p125 :151 > system 'reset'
Finalmente hizo el truco para mí!
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-17 21:07:46
Para usuarios de Windows:
Si crea un nombre de archivo bat c. bat cuyo contenido es:
@echo off
cls
Entonces, en IRB, puedes decir:
system('c')
Para limpiar la consola. Solo pensé que compartiría porque pensé que era bastante genial. Esencialmente cualquier cosa en el camino es accesible.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-06 16:19:14
->(a,b,c){x=a.method(b);a.send(c,b){send c,b,&x;false};print"\e[2J\e[H \e[D"}[irb_context,:echo?,:define_singleton_method]
Esto borrará completamente su pantalla IRB, sin líneas vacías adicionales y cosas "=> nil". Probado en Linux / Windows.
Este revestimiento único podría expandirse como:
lambda {
original_echo = irb_context.method(:echo?)
irb_context.send(:define_singleton_method, :echo?) {
send :define_singleton_method, :echo?, &original_echo
false
}
print "\e[2J\e[H \e[D"
}.call
Esto usa muchos trucos.
En primer lugar, irb llamará a echo?
para comprobar si el resultado debe imprimirse. Guardé el método, luego redefiní con un método que restaura la definación pero devuelve false para que irb no se haga eco del resultado.
En segundo lugar, imprimí algunos caracteres de control ANSI. \e[2J
will limpie la pantalla y \e[H
moverá el cursor a la posición superior izquierda de la pantalla. \e[D
imprimirá un espacio y luego moverá el cursor hacia atrás, mientras que esta es una solución para algo extraño en Windows.
Finalmente esto no es práctico en absoluto. Solo sonríe;)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-29 13:06:20
El operador backtick captura la salida del comando y la devuelve
s = `cls`
puts s
Funcionaría mejor, supongo.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-09-22 19:04:47