Sneaky way to prevent all Terminal history

Discussion in 'macOS Sierra (10.12)' started by Tech198, Jul 25, 2017.

  1. Tech198, Jul 25, 2017
    Last edited: Jul 25, 2017

    Tech198 macrumors G5

    Mar 21, 2011
    Australia, Perth
    Probably not the best route, but it works just as good without scripts, open Terminal window and type:

    defaults write AppleShowAllFiles TRUE
    "force quit" Finder.

    in %home folder% trash .bash_history file and delete contents of .bash_history folder and lock (Get info, and tick "Locked")

    - In Terminal, type history -c (probably not required)
    - reverse the showing of files as above, but use FALSE instead, and re-launch Finder again.

    All history will never be kept across any session of Terminal.:)

    Although the .bash_history fill will still be created, the fact .bash_folder cannot be written to because its locked, your good to go

    You'll get an error every time Terminal opens mkdir... but that is nothing to worry about.

    If u wish to re-enable history, just show all files again and unlock the folder.
  2. KALLT macrumors 601

    Sep 23, 2008
    You can just set up a configuration in your ".bash_profile" file. Whatever will be put in there will be executed/set whenever you start a new shell session. For example, adding:
    set +o history
    disables the history for the lifecycle of the session. Alternatively, you can also unset the history file:
    unset HISTFILE

Share This Page