👁86views
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.

CloudScale AI SEO - Article Summary
  • 1.
    What it is
    This article explains how to clear iTerm2's scroll back history using Command + K, distinguishing it from Control + L which only clears the visible screen.
  • 2.
    Why it matters
    Knowing this shortcut helps you truly clear your terminal history instead of just hiding it temporarily, which is useful for privacy or decluttering your workspace.
  • 3.
    Key takeaway
    Use Command + K in iTerm2 to permanently clear scroll back history, not Control + L which only clears the current screen.

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