Skip to content

Instantly share code, notes, and snippets.

@wheresjames
Last active March 13, 2020 10:06
Show Gist options
  • Save wheresjames/7894051b52589a731e880276462a429f to your computer and use it in GitHub Desktop.
Save wheresjames/7894051b52589a731e880276462a429f to your computer and use it in GitHub Desktop.

bash history management

# Add to ~/.bashrc
HISTCONTROL=ignoreboth:erasedups
shopt -s histappend
HISTSIZE=100000
HISTFILESIZE=200000
PROMPT_COMMAND="history -n; history -w; history -c; history -r"; $PROMPT_COMMAND
# Run from command line to clear duplicates from .bash_history
history -w && tac ~/.bash_history | awk '!x[$0]++' > ~/.bash_history.tmp && tac ~/.bash_history.tmp > ~/.bash_history && history -c && history -r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment