Skip to content

Instantly share code, notes, and snippets.

@hamidreza-s
Created April 12, 2014 05:25
Show Gist options
  • Save hamidreza-s/10520105 to your computer and use it in GitHub Desktop.
Save hamidreza-s/10520105 to your computer and use it in GitHub Desktop.
How to clear the Erlang shell.
%% move cursor to beginning of the line
io:format("\e[H").
%% clear the console
io:format("\e[J").
%% both
io:format("\e[H\e[J").
@laxmikantG
Copy link

@hamid Its not working. just says ok

@5hanth
Copy link

5hanth commented Dec 22, 2014

@laxmikantG Use the output of os:cmd("clear").
For me, io:format("\e[H\e[2J").

@magicgoose
Copy link

after running some code later, everything that was cleared is revealed again

@StoneCypher
Copy link

this actually causes the shell to emit ansi/vt control codes, where the user's terminal may or may not choose to respond. that's why scrolling "fixes" it, is that erlang has no idea that happened, and is faithfully repainting.

you can verify by setting your interpreter to dumb tty and trying this. nothing will happen.

@sher
Copy link

sher commented Oct 18, 2016

io:format(os:cmd(clear)).

@netcastdeveloper1
Copy link

congrats tudrax
io:format(os:cmd(clear)) works!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment