Skip to content

Instantly share code, notes, and snippets.

@petewarden
Created Jan 31, 2022
Embed
What would you like to do?
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