I have a script that allows me to log random thoughts while working on a project. In the terminal I would add a new log entry by running
$ @ "some random thought"
where @
is just an alias for my script.
Say my terminal is in this state:
$ ls /var/tmp
somefile.ext
another-file.l
$ _
After running my script, it would look like this:
$ ls /var/tmp
somefile.ext
another-file.l
$ @ "some random thought"
$ _
Now, I do not want that line ($ @ "some random thought"
) to stay on the screen after I enter it. I just want the script to run and leave no trace on the screen (some things are personal and some people might see my terminal). I also do not want to clear
the entire screen.
Do you think this is possible? I am using Iterm2 if this helps.
NB: I know how to handle history
so that it doesn't record my log entries. I just want to leave no trace on the screen.
Best Answer
You could try overwriting the previous line, which has already been answered;
How to change the contents of a line on the terminal as opposed to writing a new one?
For example (modified from original answer):
Will display only:
As the output. Adding more \033[1A sequences removes more lines.
Caveat: This doesn't work on all terminals.