Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rock6079

macrumors 6502
Original poster
Jan 6, 2004
428
149
how would one goabout deleting the list of previosuly used commands (by pressing up arrow) in the terminal, is there a command to do that or is it a cache type thing? ne wase it bothers me that when i quit and reopen the terminal their still their
 
I'm going to guess that you're using the bash shell. It keeps a file in your home directory called ".bash_history" that stores all of your previous commands. You could delete this file. There may also be an option in bash's config file to disable this feature.

Personally, I use the zsh shell, which does not store command histories after a logout (by default anyway).
 
reh said:
I'm going to guess that you're using the bash shell. It keeps a file in your home directory called ".bash_history" that stores all of your previous commands. You could delete this file. There may also be an option in bash's config file to disable this feature.

Personally, I use the zsh shell, which does not store command histories after a logout (by default anyway).

thanks, do u know ifthe tcsh shell is similar to the bash shell in that way or how it saves previous commands ?
 
rock6079 said:
thanks, do u know ifthe tcsh shell is similar to the bash shell in that way or how it saves previous commands ?

I think the file name is ~/.history for tcsh. You can type "man tcsh" to see all the various options - maybe you can turn history off altogether?
 
broken_keyboard said:
I think the file name is ~/.history for tcsh. You can type "man tcsh" to see all the various options - maybe you can turn history off altogether?

good call thanks
 
reh said:
I'm going to guess that you're using the bash shell. It keeps a file in your home directory called ".bash_history" that stores all of your previous commands. You could delete this file. There may also be an option in bash's config file to disable this feature.

Personally, I use the zsh shell, which does not store command histories after a logout (by default anyway).

hmm i jsut deleted .bash_history and didnt change a thing

edit: well i jsut got this from man bash
------------
HISTFILE
The name of the file in which command history is saved (see HISTORY below). The default value is ~/.bash_history. If unset,
the command history is not saved when an interactive shell exits.
------------

so u obviously werent wrong, but still weird lol

anyon have ne solutions ?
 
You said you're using tcsh? The defualt history file for tcsh is ".tcsh_history". Do you have that file? Better yet, unless there's stuff you'd rather people not see, could you list the contents of your home folder using "ls -a" and post it here? (curious what shell configuration files may be lurking)
 
Type bash or tcsh at the login prompt. A more permanent way is to set it in terminal prefs "Execute this command" (when opening a new window) and set it to /bin/bash or /bin/tcsh (though it might be /usr/bin/tcsh, just look for it). I'm pretty sure there is a login file which is executed by the login command which will set your prompt. Type man login for more info if you want to try this method.
 
MacFan26 said:
this is sort of off topic, but is there an easy way to switch between bash and tsch? or is that even something that is useful to do?
Like kyle said, you can try out each shell by just typing it's name in the terminal (bash, csh, sh, tcsh, & zsh come with panther). The cleanest way to change your default shell is to type "chsh" (stands for change shell) and then type the path of the new shell. If you're switching to bash, it would be /bin/bash
 
Terminal setups

You can specify how many commands, or no commands at all, by editing the . tcshrc file.

Just open a Terminal window and while in your home directory type:

pico .tcshrc

This opens the file in a user-friendly text editor called pico - commands you can use are listed in the bottom of the window for easy reference (and why I recommend less-skilled users to use pico and not say vi).

Then enter on a new line (use the arrow keys):

set savehist=25

To save the last 25 commands. Or delete that line (Backspace key) if it exists and you don't want to save commands.

To get a scrollback buffer of some size add a new line or edit the existing line:

set history=50

This will save the last 50 commands for the session only. Closing the window and opening a new one erases these saved commands.

Press Control o to save (press y to confirm saving) and then Control x to get out of pico. You must close any open Terminal window and reopen one to get the changes.
 
reh said:
You said you're using tcsh? The defualt history file for tcsh is ".tcsh_history". Do you have that file? Better yet, unless there's stuff you'd rather people not see, could you list the contents of your home folder using "ls -a" and post it here? (curious what shell configuration files may be lurking)

.
..
.DS_Store
.bash_history
.CFUserTextEncoding
.emacs.d
.java
.jpi_cache
.lpoptions
.ssh
.Trash
Public
Applications
Desktop
Documents
Downloads
(as u can see i didn't include the rest of the visible folders, as they are all nothing out of the ordinary)

this is all that is in my home directory, regardless of which shell i'm using, nothing changes, though ididn't expect anything to, ive dleted bash_history and everytime the commands r still there

btw where is the tcshrc file ?

hmmm

edit: i use both tcsh and bash (but bash seems to be the most stubborn wen it comes to command history as tcsh doesn't show history after i logout)

Theres a whole section under Shell Variables in the man bash file that talks about history but i don't know how to use/access those Variables ?
 
sudo pico /etc/bashrc

append the following line at the end:
unset HISTFILE


That should fix it. /etc/bashrc is included from /etc/profile ... /etc/profile contains global settings for anyone who logs in with a shell. It should be possible to edit settings for individually for a user by editing ~/.profile ... So if you're not root on the box you'll have to append "unset HISTFILE" to your .profile file instead.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.