forked from Bash-it/bash-it
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory.bash
49 lines (45 loc) · 1.08 KB
/
history.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# shellcheck shell=bash
#
# Functions for working with Bash's command history.
function _bash-it-history-init() {
safe_append_preexec '_bash-it-history-auto-save'
safe_append_prompt_command '_bash-it-history-auto-load'
}
function _bash-it-history-auto-save() {
case $HISTCONTROL in
*'noauto'* | *'autoload'*)
: # Do nothing, as configured.
;;
*'auto'*)
# Append new history from this session to the $HISTFILE
history -a
;;
*)
# Append *only* if shell option `histappend` has been enabled.
shopt -q histappend && history -a && return
;;
esac
}
function _bash-it-history-auto-load() {
case $HISTCONTROL in
*'noauto'*)
: # Do nothing, as configured.
;;
*'autosave'*)
# Append new history from this session to the $HISTFILE
history -a
;;
*'autoloadnew'*)
# Read new entries from $HISTFILE
history -n
;;
*'auto'*)
# Blank in-memory history, then read entire $HISTFILE fresh from disk.
history -a && history -c && history -r
;;
*)
: # Do nothing, default.
;;
esac
}
_bash_it_library_finalize_hook+=('_bash-it-history-init')