How to change the entire command line

Hello everyone,

This might be a weird question, and I don’t know how to ask it properly, but I really would like to know how to change the text of a command line without using print().

A good example is in this video, where the entire command line changes instead of printing every line.

Thaks!

I assume you are talking about output. In that case you print \r to move the cursor to start of the line, then print over:

julia> println("hello world\rworld")
world world

You can also print \e[K to clear the rest of the line:

julia> println("hello world\rhi\e[K")
hi

See e.g. https://en.wikipedia.org/wiki/ANSI_escape_code.

2 Likes

Thanks, that is really useful!

It is possible to clear the entire command line instead of just scrolling down?