Skip to content

Instantly share code, notes, and snippets.

@hyfen
Created June 12, 2017 01:08
Show Gist options
  • Save hyfen/a866fc010bbc4deedb3d0a360a755f88 to your computer and use it in GitHub Desktop.
Save hyfen/a866fc010bbc4deedb3d0a360a755f88 to your computer and use it in GitHub Desktop.
Save unlimited bash history in OSX
# save history to ~/.bash_history as soon as command is run
export PROMPT_COMMAND='history -a'
# save unlimited history
# osx doesn't seem to respect =-1 or = options
export HISTSIZE=9999999999
export HISTFILESIZE=999999999
# osx doesn't actually respect this and it'll fall back to unix timestamp (which we want)
export HISTTIMEFORMAT="%d/%m/%y %T "
@jayakumarc
Copy link

jayakumarc commented Mar 25, 2020

Thanks for this gist.
We can do this to keep the existing PROMPT_COMMAND,

export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment