I often use clear when I need to rerun the same command and want to see the output in isolation each time, so I might run clear && ./build.sh and then just press the up arrow and run it again.
But I think, many people are also just not aware of the keyboard shortcut or don’t care to remember it, since they don’t use it often and clear is easy enough to guess.
I guess I’m the other kind of brain. I tap Ctrl+l on cooldown. But the up arrow thing makes sense. But still doesn’t explain the alias if you’re not actually typing it often.
CTRL+L and clear command do two different things (at least when using Bash on Debian):
CTRL+L scrolls the terminal output one screen so you don’t see your previous output, unless you scroll up;
clear does indeed clear terminal output completely, and your previous command history is available only through the history command.
If you want CTRL+L to clear your screen completely you can add following to the .bashrc (or other file that is sourced when starting Bash, e.g. .bash_bindings):
bind -x '"\C-l":clear'
Note that it might not work if you use Vi mode inside Bash, but who does that.
People type
clearinstead ofCTRL+L?I’ve never had a terminal that that didn’t work in. Or at the very least have a shortcut be able to be set for.
I often use
clearwhen I need to rerun the same command and want to see the output in isolation each time, so I might runclear && ./build.shand then just press the up arrow and run it again.But I think, many people are also just not aware of the keyboard shortcut or don’t care to remember it, since they don’t use it often and
clearis easy enough to guess.I guess I’m the other kind of brain. I tap Ctrl+l on cooldown. But the up arrow thing makes sense. But still doesn’t explain the alias if you’re not actually typing it often.
CTRL+Landclearcommand do two different things (at least when using Bash on Debian):CTRL+Lscrolls the terminal output one screen so you don’t see your previous output, unless you scroll up;cleardoes indeed clear terminal output completely, and your previous command history is available only through thehistorycommand.If you want
CTRL+Lto clear your screen completely you can add following to the.bashrc(or other file that is sourced when starting Bash, e.g..bash_bindings):bind -x '"\C-l":clear'Note that it might not work if you use Vi mode inside Bash, but who does that.