How to clear the Terminal on Mac: Command, shortcut, and scrollback

5 min read

Looking for the clear Terminal Mac command? Well, depending on what you personally mean by “clear,” you’ve got three ways to do it.

If you want to clear up what's currently clogging up your screen, a quick flush is one thing, while wiping the scrollback is another, and removing all your saved command history, well, that’s something totally different.

For most Terminal users out there, and probably anyone who’d landed on this article, you’re looking for the quick answer; well, typing clear or using the Ctrl + L shortcut in Terminal is the fastest way.

But I’ll walk you through everything below in a bit more detail.

How to clear Terminal on Mac

So as I said in the intro above, if you just literally want to clear what’s currently visible in your Terminal window, type in clear and hit return. Ctrl + L works exactly the same; it’s all down to preference.

Terminal window on Mac with the clear command typed

But good to know they don’t clear the scrollback buffer because the shell doesn’t own it. So, if you do scroll up, the previous output will still be there.

For a properly clean Terminal window, including the scrollback, use Cmd - K

That’s going to work in Terminal.app and iTerm2 and remove all the old buffer as well as the visible output.

MacBook Terminal clear commands all explained

Action

Command

Info

Clear your current visible screen

Type: clear or Ctrl + L

Scrolls output out of view, but leaves your scrollback intact

Clear your screen and your scrollback

Cmd + K

Wipes the buffer so there’s nothing to scroll back to

Reset Terminal if it’s broken or not working as it should

Type: reset

Reinitializes the Terminal and fixes garbled output

Clear your saved command history

type in: history -c, plus the history file

Clears the commands stored in the current Terminal session

The biggest thing here to mention is that the clear command isn’t going to delete your previous output. Your scrollback is totally separate.

clear command vs. Mac Terminal reset command

If everything works fine in your Terminal and you just want a bit of a cleanup, then the clear command is what I’d recommend.

The MacBook Terminal reset command is only really to use when Terminal is actually broken. You just need to type in: reset

Terminal window on Mac with the reset command typed

It takes a bit longer than the clear command because it reinitializes your Terminal settings, but that’s to be expected.

If you’re not entirely sure you need to go for the big reset, you could also try typing in: stty sane. This will repair the input without the need to reset.

App-specific differences

Some keyboard shortcuts are app-specific, so I’ve tried to break these down here.

Terminal.app

The Cmd - K command will clear your screen and the scrollback buffer. But you can also go to Edit > Clear Scrollback. Another way to check Terminal’s scrollback limits is by opening Terminal and clicking on the Terminal menu (at the top) > Settings > Profiles > Window.

Terminal Settings, Profiles, Window tab with scrollback options

iTerm2

Again Cmd - K works, but you can also go up to the Edit menu option > Clear Buffer. If you only want to clear back to your last command mark, you can use: Cmd - Shift - K

Warp

To clear the current view but keep previous commands available, use:

Ctrl - L

Warp will move the existing blocks out of view, but you can still navigate back to them. If you want to remove the blocks from the Terminal view completely, use: Cmd - K

Can you remove Terminal command history?

If you’re about to screen-share, or even hand your Mac to someone else, or maybe you’ve just typed something sensitive like a token or password, and don’t want it appearing when you press the Up Arrow or run history, then clearing your history is a smart move.

One thing I will say, though, is that I find command history useful because it saves you from retyping old commands, so I’d only delete it if you’re really sure that's what you want to do. Just type in: history -c to clear the in-memory list for your current session.

Good to know. If you’ve got another Terminal window, it can write old history back to the file when it closes; make sure it’s closed down for a thorough clean.

On newer macOS, the default shell is Zsh, and its saved history lives here: ~/.zsh_history

If you want to clear it, run: > ~/.zsh_history and when you’re finished, just open up a new Terminal window.

For Bash, it’s slightly different, because the history file is usually here: ~/.bash_history

Troubleshooting tips

The clear command doesn’t always work; sometimes literally nothing happens, or in other instances the input comes straight back. From what I’ve seen on the help forums, that’s most likely because a background process is still writing to the Terminal. You can try to run this command first: Ctrl - C

If your screen clears but when you scroll you can see old output, that's expected; you’ll have to use the Cmd - K command instead.

When you’re starting to see muddled-up characters after clearing, that’s probably a bit of an indication that Terminal is broken; run the reset command.

I’ve also seen a couple of users report that the clear command returns a "not found" error message; that can mean your PATH is broken. You’ll need to run: /usr/bin/clear and fix the shell config

If you’ve been trying the history -c command but it’s not clearing, and you can still see your history, then that basically means the history file wasn't emptied, or another open session rewrote it on exit.

If you’re on a clear-up mission, but it’s really a bigger issue — and by that I mean your entire dev environment feels overloaded or cluttered — I’ve been having a lot of fun testing the new CleanMyMac CLI tool. It’s really easy to remove old developer caches without leaving the shell.

CleanMyMac CLI in Terminal showing scan results for developer caches

Install it with Brew using: brew install --cask macpaw/taps/cleanmymac-cli, and once it’s all up and running, try the: cleanmymac clean dev command.

So we've covered just about all there is on Cmd - K Terminal on Mac