You can see the current size by typing the following command.If you aren’t already comfortable with navigation in the UNIX command line, then it’s strongly recommended that you study Changing the size of the history buffer is relatively easy, and we have already seen how to do it from the third method we used above to clear history.Īll we need to do is set the value of the $HISTSIZE variable in the environment. If you check your history size and find that it is not large enough, you may want to make it bigger. So maybe the solution for your problem is not just to clear the history but to make it smaller. Adjust the History SizeĪs you can see in the last method we have used, you can set your history buffer’s size to whatever you want. You might not want someone else to be able to log in and see what commands you have run. There could also be security or privacy reasons. For example, if you are trying out a new process with a set of commands, you might want to clear everything first so that you can easily go back and see what you did for just that process. There are a variety of reasons you may need to do this. So why would I want to delete the history? It allows you to see what commands you have run and quickly go back and rerun or reuse parts of commands. Having your command history available is a great benefit. You will now see that the history has been cleared, and the only command in the history is the last export command you ran. Run the command below to see if it is there. The directory we are looking for is called. To get to your home directory, type the following command and then hit return. Use the following steps to rename the history file. It will be located in your home directory. This is a hidden directory, so if you are looking for it, you will need to use the -a parameter with your ls command to see it. For our case, we are just going to go over Z shell since that is what most Mac systems are using now. The file is usually named by the shell type and then _history. Other shells will use a file instead of a directory. For our example, we are using Z shell, so the directory we are looking for is called. If you like to use more technical solutions, you can delete (or rename if you want to save it for any reason) the directory that holds the command history data. Hit your return key, and the command history will clear. (note: For bash and many other shells, the command is history -c) In my opinion, the quickest and cleanest way to clear Terminal’s history is to use the history command with the -p (for purge) parameter. For Z shell, there are three ways that we can clear it. The command history can help us be more efficient and run commands quickly, but there are times when we need to clear the history. If needed, you can modify the parameters of that command by using your backspace or arrow keys and editing them. Just use the arrow key to bring the command back to the command prompt and then hit enter. This can come in very handy for commands that you run repetitively. The command history also lets you pull commands from your history to your command prompt by hitting the up arrow to move back through the history and the down arrow to move forward through it. We will also discuss how to set your history’s size in case you want to increase or decrease it. If you would like to see how easy it can be to clear your history and discuss some reasons why you may need to do so, keep reading below. As a frequent user, I often rely on the command history stored by my shell environment, but there are times when I need a fresh start and want to clear it. My name is Eric, and as a software engineer, I use command line interfaces like Mac Terminal all the time. To clear Terminal’s history on your Mac, you can use the history command, delete the history directory, or set history size to 0. Whatever the reason, there are a few simple ways to clear it. Mac Terminal’s Z shell saves your command history, and in some situations, you will want or need to clear that history. One great feature of almost any UNIX/LINUX-based shell environment is that it saves your command history. Like most command line interfaces, the Terminal application on Mac uses a shell environment to translate the commands you type so the computer can understand them.
0 Comments
Leave a Reply. |