plugin/history-eternal: Use `readonly` instead of `export`
...and hide errors relating to setting already-readonly variables. `plugin/history-eternal` does not need to force loading after `plugin/history` because both plugins will play nicely with read-only variables, and since we're overwritting and marking read-only then the intended result survives no matter which loads first. plugin/history-eternal: require Bash v4.3+ Unlimited history is only possible in _Bash_ version 4.3 and uppull/1940/head
parent
8052911861
commit
267a721ac6
|
|
@ -1,20 +1,22 @@
|
|||
# shellcheck shell=bash
|
||||
about-plugin 'eternal bash history'
|
||||
|
||||
# Load after the history plugin
|
||||
# BASH_IT_LOAD_PRIORITY: 375
|
||||
if [[ ${BASH_VERSINFO[0]} -lt 4 ]] || [[ ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 3 ]]; then
|
||||
_log_warning "Bash version 4.3 introduced the 'unlimited' history size capability."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Modify history sizes before changing location to avoid unintentionally
|
||||
# truncating the history file early.
|
||||
|
||||
# "Numeric values less than zero result in every command being saved on the history list (there is no limit)"
|
||||
export HISTSIZE=-1
|
||||
readonly HISTSIZE=-1 2> /dev/null || true
|
||||
|
||||
# "Non-numeric values and numeric values less than zero inhibit truncation"
|
||||
export HISTFILESIZE='unlimited'
|
||||
readonly HISTFILESIZE='unlimited' 2> /dev/null || true
|
||||
|
||||
# Use a custom history file location so history is not truncated
|
||||
# if the environment ever loses this "eternal" configuration.
|
||||
HISTDIR="${XDG_STATE_HOME:-${HOME?}/.local/state}/bash"
|
||||
[[ -d ${HISTDIR?} ]] || mkdir -p "${HISTDIR?}"
|
||||
export HISTFILE="${HISTDIR?}/history"
|
||||
readonly HISTFILE="${HISTDIR?}/history" 2> /dev/null || true
|
||||
|
|
|
|||
Loading…
Reference in New Issue