Wholesale cleanup of all history plugins
- remove the use of redundant cite - minor cleanups to history.plugin.bash - set explicit load orders for history-search and history-substring-search - add new plugin history-eternal - replace superfluous trap for managing HISTTIMEFORMAT changespull/1982/head
parent
036cf8ada0
commit
bdb5289660
|
|
@ -92,6 +92,7 @@ plugins/available/docker-machine.plugin.bash
|
||||||
plugins/available/git.plugin.bash
|
plugins/available/git.plugin.bash
|
||||||
plugins/available/go.plugin.bash
|
plugins/available/go.plugin.bash
|
||||||
plugins/available/goenv.plugin.bash
|
plugins/available/goenv.plugin.bash
|
||||||
|
plugins/available/history-eternal.plugin.bash
|
||||||
plugins/available/history-search.plugin.bash
|
plugins/available/history-search.plugin.bash
|
||||||
plugins/available/history-substring-search.plugin.bash
|
plugins/available/history-substring-search.plugin.bash
|
||||||
plugins/available/history.plugin.bash
|
plugins/available/history.plugin.bash
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# "Non-numeric values and numeric values less than zero inhibit truncation"
|
||||||
|
export HISTFILESIZE='unlimited'
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
cite about-plugin
|
|
||||||
about-plugin 'search history using the prefix already entered'
|
about-plugin 'search history using the prefix already entered'
|
||||||
|
|
||||||
|
# Load after the history plugin
|
||||||
|
# BASH_IT_LOAD_PRIORITY: 375
|
||||||
|
|
||||||
# enter a few characters and press UpArrow/DownArrow
|
# enter a few characters and press UpArrow/DownArrow
|
||||||
# to search backwards/forwards through the history
|
# to search backwards/forwards through the history
|
||||||
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
cite about-plugin
|
|
||||||
about-plugin 'search history using the substring already entered'
|
about-plugin 'search history using the substring already entered'
|
||||||
|
|
||||||
|
# Load after the history plugin
|
||||||
|
# BASH_IT_LOAD_PRIORITY: 375
|
||||||
|
|
||||||
# enter a few characters and press UpArrow/DownArrow
|
# enter a few characters and press UpArrow/DownArrow
|
||||||
# to search backwards/forwards through the history
|
# to search backwards/forwards through the history
|
||||||
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
cite about-plugin
|
|
||||||
about-plugin 'improve history handling with sane defaults'
|
about-plugin 'improve history handling with sane defaults'
|
||||||
|
|
||||||
# append to bash_history if Terminal.app quits
|
# Append the history list to the file named by the value of the HISTFILE
|
||||||
|
# variable when the shell exits, rather than overwriting the file.
|
||||||
shopt -s histappend
|
shopt -s histappend
|
||||||
|
|
||||||
# erase duplicates; alternative option: export HISTCONTROL=ignoredups
|
# erase duplicates; alternative option: export HISTCONTROL=ignoredups
|
||||||
|
|
@ -11,19 +11,17 @@ export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups}
|
||||||
# resize history to 100x the default (500)
|
# resize history to 100x the default (500)
|
||||||
export HISTSIZE=${HISTSIZE:-50000}
|
export HISTSIZE=${HISTSIZE:-50000}
|
||||||
|
|
||||||
top-history() {
|
# Flush history to disk after each command.
|
||||||
|
export PROMPT_COMMAND="history -a;${PROMPT_COMMAND}"
|
||||||
|
|
||||||
|
function top-history() {
|
||||||
about 'print the name and count of the most commonly run tools'
|
about 'print the name and count of the most commonly run tools'
|
||||||
|
|
||||||
if [[ -n $HISTTIMEFORMAT ]]; then
|
# - Make sure formatting doesn't interfer with our parsing
|
||||||
# To parse history we need a predictable format, which HISTTIMEFORMAT
|
# - Use awk to count how many times the first command on each line has been called
|
||||||
# gets in the way of. So we unset it and set a trap to guarantee the
|
# - Truncate to 10 lines
|
||||||
# user's environment returns to normal even if the pipeline below fails.
|
# - Print in column format
|
||||||
# shellcheck disable=SC2064
|
HISTTIMEFORMAT='' history \
|
||||||
trap "export HISTTIMEFORMAT='$HISTTIMEFORMAT'" RETURN
|
|
||||||
unset HISTTIMEFORMAT
|
|
||||||
fi
|
|
||||||
|
|
||||||
history \
|
|
||||||
| awk '{
|
| awk '{
|
||||||
a[$2]++
|
a[$2]++
|
||||||
}END{
|
}END{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue