One of the great things about using a powerful tool like Terminal on Mac is the abundance of output it provides, which allows you to see what is happening every time you type a command into the interface. After a while, it can become overwhelming and start to clutter up your screen.
Once you have the information you need, it is often nice to be able to clear your screen so that you can easily see the output from the next command that you type. Thankfully you can clear the terminal screen on your Mac using a simple command, pressing a couple of shortcut keys, or using the Terminal menu.
My name is Eric, and I have been using command-line interfaces such as Terminal for many years. I know the importance of being able to clear your Terminal screen so that you can start over with fresh data when needed.
Below, I will show you how to quickly do this, and I will also show you how to clear the data that you see if you scroll back on your Terminal screen.
Contents
Type the command
The quickest and easiest method is to just type the clear command in your Terminal window. It’s the method I always use, and it has become second nature to me.
Just type the command by itself, as shown below.
clear
Then hit return/enter, and your Terminal screen will be cleared.
Use the Keyboard Shortcut
You can do the same thing using a keyboard shortcut. This one is straightforward as well, but I often do not think of using it. Just press the CONTROL+COMMAND+L keys, and your screen will clear.
One more method you can use is the Terminal menu. Just click on Edit on the menu at the top of the screen and select Clear Screen.
Clear Scrollback
When clearing the screen using the command above, you might have noticed that only the visible part of your Terminal screen is cleared. If you scroll back up the window, you will see that all the data is still there.
The clear command has really just entered a bunch of new lines until all the data has left your current viewable screen. This works well for most situations, but there are times when you want to clear all the data that is viewable even when scrolling back.
For this, you can use the Clear Scrollback selection on the menu shown below, or you can use the keyboard and press OPTION+COMMAND+K.
When looking at the edit menu, you may have noticed some other options for clearing data. You can try these out to see how they work if you would like.
Clear to Previous Mark
Clear to Previous BookMark
Clear to Start
Notice from the menu that these actions also have key combinations that you can use to execute them.
If you have text selected on the screen, you will also see an option to Clear to Start of Selection.
FAQ
Here are some common questions I frequently see when talking about clearing the screen.
What is the difference between clearing the screen and clearing scrollback?
Clearing the screen only clears the visible area on your Terminal window. If you scroll up or back in the window, you can still see the previous output. Clear Scrollback clears all the data, even the data you would see if you scroll back in the Terminal window.
Does Clearing Scrollback clear my command history?
No, it only clears the output that has been shown on the screen, but your shell will still contain your command history, and you can see it by typing the history command.
Can I use the cls command to clear my screen?
The cls command is a common command used on other systems like MS-DOS, but it is not standard in your Terminal’s BASH shell. If you really want to use cls to clear the screen, you could create an alias that will run the clear command when you type cls.
Just put the following line in your /home/user/.bashrc file.
alias cls=”clear”
Conclusion
There are multiple ways you can clear your Terminal screen. You can use the clear command, the keyboard shortcut, or even the Terminal menu. As we can see on the Terminal menu, there are also different types of screen-clearing that you can do.
I hope the information I have provided above can help you clear your Terminal screen on your Mac when needed. Let me know if you have any questions or comments. I would love to hear from you!