clearing command history from terminal

Is there a way to clear all the history of remembered commands in Terminal? I am referring to the "Run Command" box after "New Command" is selected showing the most recent command highlighted and a collection of recent commands in a "scroll down" underneath this. They wont delete permanently. Same ones reappear each time box is closed and "new command" is selected.

Is it any problem if I am unable to clear them? I believe it is normal for the computer to remember these recent commands. Thanks

Mac OS X (10.4.11)

Posted on Mar 14, 2008 7:44 AM

Reply
8 replies

Mar 14, 2008 12:12 PM in response to WZZZ

Thanks for reply. First, I am referring to the history of remembered commands as shown in the drop down that appears after "new command" is selected and includes the last command entered, which is highlighted. Is this what you understood I was referring to?

Second, by "bash" do you mean the window that appears when terminal is opened? The window I am seeing is titled "terminal-tcsh-80X24" Lower down it says "welcome to Darwin" plus some other text. In an article "Mac OS X: How to change the Terminal shell" it is written that tcsh as default is meant for pre 10.4 systems and bash as default for 10.4 (which I am running). Does this mean I have the wrong default shell?

Third, I never use Terminal. I don't understand Unix and only got into this by accident (too long a story). I just want to make sure I haven't disturbed anything that will upset the computer. Since all of this is unfamiliar I would be grateful for an answer that includes more detail and explanation. Thanks for your patience.

Mar 14, 2008 1:19 PM in response to WZZZ

No Sorry, I have you not understood correctly. These was an instruction to clear the history direct in the shell.

The history from the drop down menu stand in the com.apple.Terminal.plist Preference file in
Library/Preferences
in your homefolder. You can delete the preference file, or you could create an AppleScript with the command
do shell script "defaults delete com.apple.Terminal CommandHistory"
because the terminal write at quit the historycache back to the preference file, when you run the command direct in the shell.

No. When you open an terminal window, you awake the standard shell. In your case the tcsh. This is not the wrong shell, it is familiarization, wich you favored. I don´t know, why you have the tcsh as standard.

Mar 14, 2008 6:26 PM in response to Zerwas

Are you saying that I should delete (or drag to the trash) the entire "com.apple.Terminal.plist" file (shows as a document) found in "users/name/library/preferences"? Apple support article, "Mac OSX 10.4 Reading Plist Files"), says the following: "Important: You should not usually modify preference files directly. Instead, you should use the associated application's Preferences menu(s) to customize your settings."

I don't see any way of removing command history in Terminal Preferences.

I noticed that this file was only created today when I started working with Terminal. Does this then mean it is not essential to Terminal working properly? Thanks for help.

Mar 15, 2008 5:52 AM in response to WZZZ

Yes, when an application have an Preference menu, you should use them to set the settings. If the Preference menu has not an option to set or remove an setting, in this case the history, you could use
defaults


This is also an official way to modify Preference files, when the Application or Process have not an Preference dialog, or the funktion is not implemented.

To delete the Preference file is a simply methode, but not the best, because you lost all settings.
Better you use an AppleScript to modify the setting.

Create an AppleScript and write the command in the last post into. Then close the Terminal and run the AppleScript. At the next start of the Terminal, the history drop down should be clear.

Mar 15, 2008 6:13 AM in response to Zerwas

This is is good method, very well thought out. Yet I see no need for this. It does not consume disk space and is a good reference for future use. Why not leave it be. If you ever need a check-up, Apple can look back to see what may have led to the problem. Trust me, leave it the way it is and forget of it. Like I claimed, it uses no disk space.

Ray

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

clearing command history from terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.