Created
December 5, 2022 09:26
-
-
Save elchead/f3135f872ff3dc66ee3e9681aaea2c9a to your computer and use it in GitHub Desktop.
Consistent bash history across sessions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export HISTCONTROL=ignoredups:erasedups # no duplicate entries | |
| export HISTSIZE=100000 # big big history | |
| export HISTFILESIZE=100000 # big big history | |
| # shopt -s histappend # append to history, don't overwrite it | |
| # Save and reload the history after each command finishes | |
| #export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" | |
| HISTCONTROL=ignorespace:ignoredups | |
| _bash_history_sync() { | |
| builtin history -a #1 | |
| HISTFILESIZE=$HISTSIZE #2 | |
| builtin history -c #3 | |
| builtin history -r #4 | |
| } | |
| history() { #5 | |
| _bash_history_sync | |
| builtin history "$@" | |
| } | |
| PROMPT_COMMAND=_bash_history_sync | |
| # Source https://unix.stackexchange.com/a/48116 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment