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 4141__bp_imported=" defined"
4242
4343
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+ }
4956
5057# This variable describes whether we are currently in "interactive mode";
5158# i.e. whether this shell has just executed a prompt and is waiting for user
@@ -188,6 +195,9 @@ __bp_preexec_and_precmd_install() {
188195 return 1;
189196 fi
190197
198+ # Adjust our HISTCONTROL Variable if needed.
199+ __bp_adjust_histcontrol
200+
191201 # Take our existing prompt command and append a semicolon to it
192202 # if it doesn't already have one.
193203 local existing_prompt_command
Original file line number Diff line number Diff line change @@ -114,9 +114,22 @@ test_preexec_echo() {
114114
115115}
116116
117- @test " HISTCONTROL should remove ignorespace" {
117+ @test " __bp_adjust_histcontrol should remove ignorespace and ignoreboth " {
118118
119+ # Should remove ignorespace
119120 HISTCONTROL=" ignorespace:ignoredups:*"
120- HISTCONTROL= " ${HISTCONTROL // ignorespace} "
121+ __bp_adjust_histcontrol
121122 [[ " $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+
122135}
You can’t perform that action at this time.
0 commit comments