Is there a command in IPython to clear the screen?
EDIT: As @Saher mentions below, I can clean the screen using import os; os.system('CLS')
, but is there a way to do this without having to import all of os
?
To clear the screen on Windows, use !CLS
.
On Unix-like systems, use !clear
.
A shell command is executed by the operating system if prepended by an exclamation mark. See http://ipython.readthedocs.io/en/stable/interactive/reference.html#system-shell-access.
Note that commands should also work without the exclamation mark if they are defined as aliases. See http://ipython.readthedocs.io/en/stable/interactive/shell.html?#aliases.
There is also a Ctrl+L shortcut for clearing the screen. See http://ipython.readthedocs.io/en/stable/config/shortcuts/index.html#single-filtered-shortcuts.
You can bind it to the common Ctrl-l shortcut by putting this into your ~/.ipython/ipythonrc
:
readline_parse_and_bind "\C-l": clear-screen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With