I am using the following as a workaround:
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=erasedups:ignorespace
export HISTSIZE=1000
export HISTIGNORE="history *:cd *:df *:exit:fg:bg:file *:ll:ls:mc:top:clear"
export HISTFILESIZE=10000
#avoid overwriting history
shopt -s histappend
#smart handling of multi-line commands
shopt -s cmdhist
# append every command to history
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
But I still need to remove duplicates from time to time:
#!/usr/bin/perl
use strict;
my $histfile = `echo ~/.bash_history`;
open(INPUT, "<$histfile") or die "Can't open $histfile: $!\n";
my @lines = reverse <INPUT>;
close(INPUT);
print "Before: ". scalar(@lines). " lines\n";
my @buffer = ();
for (my $i = 0; $i < @lines; $i++) {
$lines[$i] =~ s/\s+\n$/\n/;
}
while (@lines) {
my $line = shift @lines;
push (@buffer, $line) unless $line =~ /^mplayer|^rm/;
@lines = grep { $_ ne $line } @lines;
}
open(OUTPUT, ">$histfile") or die "Can't open $histfile: $!\n";
print OUTPUT reverse @buffer;
close(OUTPUT);
print "After: ". scalar(@buffer). " lines\n";
exit(0);
Not sure why you have "history -r". Is it fast enough?
--
bash HISTCONTROL=erasedups should erase duplicates from history file before
saving
https://bugs.launchpad.net/bugs/189881
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs