すべてを保存(firefoxのhistory編)
すべてを保存その2
firefoxのhistoryも保存すべきだろうと思った。
でも、history.datファイルはmorkという変態的形式で書かれており、見てもさっぱりわからなかった。
結局、mork.plをhttp://www.jwz.org/hacks/mork.plからとって来て、
--- mork.pl Tue Aug 8 16:20:42 2006 +++ savehistory.pl Tue Aug 8 16:12:41 2006 @@ -399,7 +399,9 @@ sub format_urls { my ($results, $html_p) = @_; - + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); + my ($today, $target); + print "<TABLE BORDER=0 CELLPADDING=" . ($show_all_p ? "4" : "0") . " CELLSPACING=0>\n" if ($html_p); @@ -475,7 +477,13 @@ print "<TD VALIGN=TOP><A HREF=\"$url\">$u2</A></TD>"; print "</TR>\n"; } else { - print "$date\t$count\t$url\n"; + $today = strftime("%Y-%m-%d", localtime (time)); + $target = strftime("%Y-%m-%d", localtime ($date)); + + if ($today eq $target){ + $date = strftime("%Y-%m-%d %k:%M:%S", localtime ($date)); + print "$date\t$count\t$url\n"; + } } } }
というパッチをあてて、当日分だけを取り出すようにしてみた。
あとは、これをラップするスクリプトを書いて(上記perlの中でしてもいいんだけどね)
#!/bin/sh targetpath="$HOME/lines/save-everything/" today=`date '+%Y/%m/%d/'` cmdhistoryfilename="command-history" urlhistoryfilename="url-history" now=`date '+%Y/%m/%d %H:%M:%S'` savehistory.pl ".mozilla/firefox/7cjzy8s6.default/history.dat" > $targetpath$today$urlhistoryfilename
cronと.zlogoutに書いておけばおーけー。