File tree Expand file tree Collapse file tree 4 files changed +57
-7
lines changed Expand file tree Collapse file tree 4 files changed +57
-7
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ completion/available/wpscan.completion.bash
8181
8282# libraries
8383lib/helpers.bash
84+ lib/history.bash
8485lib/log.bash
8586lib/preexec.bash
8687lib/utilities.bash
Original file line number Diff line number Diff line change 1+ #  shellcheck shell=bash
2+ # 
3+ #  Functions for working with Bash's command history.
4+ 
5+ function  _bash-it-history-init()  {
6+ 	safe_append_preexec ' _bash-it-history-auto-save' 
7+ 	safe_append_prompt_command ' _bash-it-history-auto-load' 
8+ }
9+ 
10+ function  _bash-it-history-auto-save()  {
11+ 	case  $HISTCONTROL  in 
12+ 		* ' noauto' *  | * ' autoload' * )
13+ 			:  #  Do nothing, as configured.
14+ 			;;
15+ 		* ' auto' * )
16+ 			#  Append new history from this session to the $HISTFILE
17+ 			history  -a
18+ 			;;
19+ 		* )
20+ 			#  Append *only* if shell option `histappend` has been enabled.
21+ 			shopt  -q histappend &&  history  -a &&  return 
22+ 			;;
23+ 	esac 
24+ }
25+ 
26+ function  _bash-it-history-auto-load()  {
27+ 	case  $HISTCONTROL  in 
28+ 		* ' noauto' * )
29+ 			:  #  Do nothing, as configured.
30+ 			;;
31+ 		* ' autosave' * )
32+ 			#  Append new history from this session to the $HISTFILE
33+ 			history  -a
34+ 			;;
35+ 		* ' autoloadnew' * )
36+ 			#  Read new entries from $HISTFILE
37+ 			history  -n
38+ 			;;
39+ 		* ' auto' * )
40+ 			#  Blank in-memory history, then read entire $HISTFILE fresh from disk.
41+ 			history  -a &&  history  -c &&  history  -r
42+ 			;;
43+ 		* )
44+ 			:  #  Do nothing, default.
45+ 			;;
46+ 	esac 
47+ }
48+ 
49+ _bash_it_library_finalize_hook+=(' _bash-it-history-init'  )
Original file line number Diff line number Diff line change @@ -5,15 +5,14 @@ about-plugin 'improve history handling with sane defaults'
55#  variable when the shell exits, rather than overwriting the file.
66shopt  -s histappend
77
8- #  erase duplicates; alternative option: HISTCONTROL=ignoredups
9- :  " ${HISTCONTROL:= ignorespace: erasedups} " 
8+ #  'ignorespace': don't save command lines which begin with a space to history
9+ #  'erasedups' (alternative 'ignoredups'): don't save duplicates to history
10+ #  'autoshare': automatically share history between multiple running shells
11+ :  " ${HISTCONTROL:= ignorespace: erasedups: autoshare} " 
1012
1113#  resize history to 100x the default (500)
1214:  " ${HISTSIZE:= 50000} " 
1315
14- #  Flush history to disk after each command.
15- export  PROMPT_COMMAND=" history -a;${PROMPT_COMMAND} " 
16- 
1716function  top-history()  {
1817	about ' print the name and count of the most commonly run tools' 
1918
Original file line number Diff line number Diff line change @@ -584,6 +584,7 @@ function aws_profile {
584584}
585585
586586function  _save-and-reload-history()  {
587- 	local  autosave=${1:- 0} 
588- 	[[ $autosave  -eq  1 ]] &&  history  -a &&  history  -c &&  history  -r
587+ 	local  autosave=" ${1:- ${HISTORY_AUTOSAVE:- 0} } " 
588+ 	[[ ${autosave}  -eq  1 ]] &&  local  HISTCONTROL=" ${HISTCONTROL:- }${HISTCONTROL: +: } autoshare" 
589+ 	_bash-it-history-auto-save &&  _bash-it-history-auto-load
589590}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments