fixup history syncing for HISTCONTROL=ignoredups

parent 764de50c
......@@ -68,10 +68,12 @@ Overview of changes in v9.2 "Galvanize"
* History Sync changes:
+ BashStyle-NG 9.1 introduced a custom history sync functionality (for syncing
history over simultaneously running sessions), which turned out not to properly
operate when the History Control Type was set to "Erase Duplicates"
operate when the History Control Type was set to "Erase Duplicates", or
"Ignore Duplicates"
.
This is now worked around by a custom _erasehistorydups function, which does
the clean-up where Bash fails due to the custom history handling functions.
This is now worked around by _erasehistorydups respectively _ingorehistorydups
functions, which do the clean-up where Bash fails due to the custom history
handling functions.
.
please note that this might slow down Bash a bit if you have a huge history
......
......@@ -202,6 +202,13 @@ if [[ $(ini_get history_sync) == True ]]; then
mv ${HISTFILE}.tmp ${HISTFILE}
}
_ignorehistorydups () {
sed '$!N;s/\n/HISTDILIMITER/' ${HISTFILE} | \
gawk -F'HISTDILIMITER' '!x[$2]++' | \
sed -e 's/HISTDILIMITER/\n/g' > ${HISTFILE}.tmp
mv ${HISTFILE}.tmp ${HISTFILE}
}
_synchistory () {
builtin history -a
builtin history -c
......@@ -212,6 +219,7 @@ if [[ $(ini_get history_sync) == True ]]; then
trap_add '_synchistory' DEBUG
[[ ${HISTCONTROL} == erasedups ]] && trap_add '_erasehistorydups' DEBUG
[[ ${HISTCONTROl} == ignoredups ]] && trap_add '_ignorehistorydups' DEBUG
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment