command history in terminal

Discussion in 'Mac Apps and Mac App Store' started by rock6079, Aug 15, 2004.

  1. rock6079 macrumors 6502

    Joined:
    Jan 6, 2004
    #1
    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
     
  2. reh macrumors 6502a

    Joined:
    Oct 24, 2003
    Location:
    Arkansas
    #2
    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).
     
  3. rock6079 thread starter macrumors 6502

    Joined:
    Jan 6, 2004
    #3
    thanks, do u know ifthe tcsh shell is similar to the bash shell in that way or how it saves previous commands ?
     
  4. broken_keyboard macrumors 65816

    broken_keyboard

    Joined:
    Apr 19, 2004
    Location:
    Secret Moon base
    #4
    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?
     
  5. rock6079 thread starter macrumors 6502

    Joined:
    Jan 6, 2004
    #5
    good call thanks
     
  6. rock6079 thread starter macrumors 6502

    Joined:
    Jan 6, 2004
    #6
    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 ?
     
  7. reh macrumors 6502a

    Joined:
    Oct 24, 2003
    Location:
    Arkansas
    #7
    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)
     
  8. MacFan26 macrumors 65816

    MacFan26

    Joined:
    Jan 8, 2003
    Location:
    San Francisco, California
    #8
    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?
     
  9. kylos macrumors 6502a

    kylos

    Joined:
    Nov 8, 2002
    Location:
    MI
    #9
    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.
     
  10. reh macrumors 6502a

    Joined:
    Oct 24, 2003
    Location:
    Arkansas
    #10
    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
     
  11. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #11
    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.
     
  12. rock6079 thread starter macrumors 6502

    Joined:
    Jan 6, 2004
    #12
    .
    ..
    .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 ?
     
  13. gekko513 macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #13
    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.
     
  14. MacFan26 macrumors 65816

    MacFan26

    Joined:
    Jan 8, 2003
    Location:
    San Francisco, California
    #14
    thanks kyle and reh :)
     

Share This Page