Make console.clear output a control sequence that clears the terminal
#8,036 opened on Jan 7, 2024
Description
What is the problem this feature would solve?
Hi, I am using bun --hot . and it clears the console just fine when used like this, but in my case I am doing nohup bun --hot . & tail -f nohup.out so that I can still listen to the Bun output but have the process keep on running when I close my terminal. This workflow is for a personal project where I am both the developer and the sole user of the web app and this is how I ensure I don't take the app down when I close my editor. By default it always runs and when I happen to be working on it, I get to see the output for troubleshooting. The problem is the default console clearing logic stops working when I do this and even explicitly calling console.clear() doesn't work.
What is the feature you are proposing to solve the problem?
console.log('\x1B[2J\x1B[H');
This clears the whole screen and homes the cursor. See https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences.
What alternatives have you considered?
This is super low priority so the alternative is to not bother doing this. I do not see a downside to this though. Maybe it is not a good idea to print control sequences to file and I just don't know? In any case, I would like to see this done if it is easy and there is no downside and I'll be equally happy to see it rejected if there is a reason it doesn't make sense.