Skip to content

Instantly share code, notes, and snippets.

@hamidreza-s
Created April 12, 2014 05:25
Show Gist options
  • Select an option

  • Save hamidreza-s/10520105 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

@hamid Its not working. just says ok

@5hanth

5hanth commented Dec 22, 2014

Copy link
Copy Markdown

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

@magicgoose

Copy link
Copy Markdown

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

@StoneCypher

Copy link
Copy Markdown

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

sher commented Oct 18, 2016

Copy link
Copy Markdown

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

@netcastdeveloper1

Copy link
Copy Markdown

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