Skip to content

Instantly share code, notes, and snippets.

@petewarden
Created January 31, 2022 23:41
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petewarden/0c653bd41cb225ded69ed9af3a0c8c34 to your computer and use it in GitHub Desktop.
Save petewarden/0c653bd41cb225ded69ed9af3a0c8c34 to your computer and use it in GitHub Desktop.
Bash history settings to tweak for infinite history, instant appending of commands, and shared history across multiple terminals.
# By Pete Warden, @petewarden
# To use this, open ~/.bashrc in your editor of choice,
# and place these settings at the end.
# Based on https://unix.stackexchange.com/a/48113 and
# https://blog.sanctum.geek.nz/better-bash-history/
# Ignore both duplicate commands, and those that start with a space.
HISTCONTROL=ignoreboth
# Append to the history file, don't overwrite it.
shopt -s histappend
# Make the maximum size of the history file enormous.
HISTSIZE=1000000
HISTFILESIZE=20000000
# This makes the entries easy to sort by time.
HISTTIMEFORMAT='%F %T '
# Store each command in the history immediately, not on session close.
PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment