iTerm2: Clear Scroll Back History with Command + K
Pressing Command + K in iTerm2 clears the entire scroll back history buffer, permanently removing all previous output from the session. Control + L only clears the visible screen but leaves the scroll back history intact, meaning past output reappears when you scroll up. Use Command + K whenever you need a completely fresh, history free terminal session.
iTerm2: Clear Scroll Back History with Command + KAndrew Baker's Technology Blog Posts, 11/May/2023
https://andrewbaker.ninja/2023/05/11/iterm2-clear-scroll-back-history-with-command-k/
I frequently forget this command shortcut, so this post is simply because I am lazy. To clear your history in iTerm press Command + K. Control + L only clears the screen, so as soon as you run the next command you will see the scroll back again.
If you want to view your command history (for terminal) type:
$ ls -a ~ | grep hist
.zsh_history
$ cat .zsh_history
I’d prefer to use `less $HISTFILE`
So, no matter what you name the command line history file