Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save swipswaps/0953d34a523bccef213528d6d0dfba08 to your computer and use it in GitHub Desktop.
Save swipswaps/0953d34a523bccef213528d6d0dfba08 to your computer and use it in GitHub Desktop.
The Best Bash History Settings Ever
#!/usr/bin/env bash
# /etc/profile.d/best_bash_history.sh
# Save 5,000 lines of history in memory
HISTSIZE=10000
# Save 2,000,000 lines of history to disk (will have to grep ~/.bash_history for full listing)
HISTFILESIZE=2000000
# Append to history instead of overwrite
shopt -s histappend
# Ignore redundant or space commands
HISTCONTROL=ignoreboth
# Ignore more
HISTIGNORE='ls:ll:ls -alh:pwd:clear:history'
# Set time format
HISTTIMEFORMAT='%F %T '
# Multiple commands on one line show up as a single line
shopt -s cmdhist
# Append new history lines, clear the history list, re-read the history list, print prompt.
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
#installation notes
#Debian 9.1: cd ~/Downloads/; sudo chmod u+x best_bash_history.sh; sudo cp best_bash_history.sh /usr/local/bin/; sudo best_bash_history.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment