Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: maximum value for HISTSIZE ?



Hi Carlos,

good to see that I'm not alone. :-)

> As a workaround I do the following:
> ...
Yep, same here.

Yesterday I wrote a simple perl script which will run weekly
and cleans up my history file.

Basically it does the following to delete all simple lines:
 (watch out, it contains lots of personal aliases)

# `:<beginning time>:<elapsed seconds>;<command>'.
# Warning: <command> can contain multiple lines (with \ at line end)
my ($line, $cmd, $continued, $lastLinePrinted);
$lastLinePrinted=0;
while ($line = <STDIN>)
{
  if ($continued and $lastLinePrinted)
  {
    print $line;
    $continued=($line =~ /\\$/);   # still continued?
    next;
  }

  # new history event
  if (not $line =~ /^:[^:]+:[^;]+;(.*)$/)
  {
    print STDERR "skipping invalid zsh-history line in line $..\n";
    next;
  }
  $cmd = $1;
  $continued=1 if $cmd =~ /\\$/;

  # short commands/aliases without arguments
  next if $cmd =~ /^(bb|ls|l|ltr|lS|cd)*$/;

  # don't skip more complex commands
  if (not $cmd =~ /&|;|\|/)
  {
    # short often used commands without options
    next if $cmd =~ /^(l|ls|ll|lh|ltr|lltr|fff|xv|rm|rd|(d)?loc(ate)?|stat|g(un)?zip|b(un)?zip2|unzip|run-help|where|which|gimp|ping|(tk)?diff|cat|adr|kill|sr (google|ebay)|qiv-max|mutt|disown) +[^-]/;

    # short often used commands with some options
    next if $cmd =~ /^(rm -(r|rf)|l(s|l|h)? -(d|R|u)|rd -p|gzip -9|bzip2 -9|diff -r|du -(sh|h|s)) +[^-]/;

    # specials
    next if $cmd =~ /^cd (diario|~\/diario)/;
    next if $cmd =~ /^(heute|diario|stunden)/;

    # keep mplayer with options OR some arg with a colon
    next if $cmd =~ /^\\?mplayer[^ ]* +[^-]/ and not $cmd =~ /^\\?mplayer[^ ]* +.*:/;
  }

  # okay, line ist interesting enough -> keep it
  print $line;
  $lastLinePrinted=1;
}

Suggestions are very welcome!

Bye,
 Andy.

-- 
 You should aim to be independent of any one vote, of any one fashion,
 of any one century.  (Baltasar Gracián, Spanish writer)



Messages sorted by: Reverse Date, Date, Thread, Author