File tree Expand file tree Collapse file tree 2 files changed +30
-7
lines changed Expand file tree Collapse file tree 2 files changed +30
-7
lines changed Original file line number Diff line number Diff line change 41
41
__bp_imported=" defined"
42
42
43
43
44
- # Remove ignorespace from HISTCONTROL so we can accurately
45
- # invoke preexec with a command from our history even if it
46
- # starts with a space.
47
- export HISTCONTROL=" ${HISTCONTROL// ignorespace} "
48
-
44
+ # Remove ignorespace and or replace ignoreboth from HISTCONTROL
45
+ # so we can accurately invoke preexec with a command from our
46
+ # history even if it starts with a space.
47
+ __bp_adjust_histcontrol () {
48
+ local histcontrol
49
+ histcontrol=" ${HISTCONTROL// ignorespace} "
50
+ # Replace ignoreboth with ignoredups
51
+ if [[ " $histcontrol " == * " ignoreboth" * ]]; then
52
+ histcontrol=" ignoredups:${histcontrol// ignoreboth} "
53
+ fi ;
54
+ export HISTCONTROL=" $histcontrol "
55
+ }
49
56
50
57
# This variable describes whether we are currently in "interactive mode";
51
58
# i.e. whether this shell has just executed a prompt and is waiting for user
@@ -188,6 +195,9 @@ __bp_preexec_and_precmd_install() {
188
195
return 1;
189
196
fi
190
197
198
+ # Adjust our HISTCONTROL Variable if needed.
199
+ __bp_adjust_histcontrol
200
+
191
201
# Take our existing prompt command and append a semicolon to it
192
202
# if it doesn't already have one.
193
203
local existing_prompt_command
Original file line number Diff line number Diff line change @@ -114,9 +114,22 @@ test_preexec_echo() {
114
114
115
115
}
116
116
117
- @test " HISTCONTROL should remove ignorespace" {
117
+ @test " __bp_adjust_histcontrol should remove ignorespace and ignoreboth " {
118
118
119
+ # Should remove ignorespace
119
120
HISTCONTROL=" ignorespace:ignoredups:*"
120
- HISTCONTROL= " ${HISTCONTROL // ignorespace} "
121
+ __bp_adjust_histcontrol
121
122
[[ " $HISTCONTROL " == " :ignoredups:*" ]]
123
+
124
+ # Should remove ignoreboth and replace it with ignoredups
125
+ HISTCONTROL=" ignoreboth"
126
+ __bp_adjust_histcontrol
127
+ [[ " $HISTCONTROL " == " ignoredups:" ]]
128
+
129
+ # Handle a few inputs
130
+ HISTCONTROL=" ignoreboth:ignorespace:some_thing_else"
131
+ __bp_adjust_histcontrol
132
+ echo " $HISTCONTROL "
133
+ [[ " $HISTCONTROL " == " ignoredups:::some_thing_else" ]]
134
+
122
135
}
You can’t perform that action at this time.
0 commit comments