Skip to content

Commit

Permalink
plugin/history-eternal: Use readonly instead of export
Browse files Browse the repository at this point in the history
...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.
  • Loading branch information
gaelicWizard committed Jan 26, 2022
1 parent 998614b commit d0bd976
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions plugins/available/history-eternal.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# shellcheck shell=bash
about-plugin 'eternal bash history'

# Load after the history plugin
# BASH_IT_LOAD_PRIORITY: 375

# 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

# "Non-numeric values and numeric values less than zero inhibit truncation"
export HISTFILESIZE='unlimited'
readonly HISTFILESIZE='unlimited' 2> /dev/null

# 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

0 comments on commit d0bd976

Please sign in to comment.