; $Id: storehist.tf,v 1.1 1996/11/24 20:23:12 dmoore Exp $ ; v1.0 ; *** Requires tf3.5a18 or later to use. *** ; (May work with earlier versions. -- although slower pre 3.5a18) ; ; *** Requires unix or at least sed. *** ; ; dmoore@ucsd.edu ;; To save some histories before you log out: ; ; /store_history -wdruid ~/tf.hist ; /store_history -wimbris ~/tf.hist ; /store_history -wcave ~/tf.hist ; /store_history -g ~/tf.hist ; /quit ; ;; After you restart tf: ; ; /restore_history ~/tf.hist ; ;; Restore_history doesn't remove the file, so you should do that ;; either before you save the next time, or after you've restored. ;; Note reloading -i history has a tendency to make tf core dump. :) ;; So you might want to avoid this: ; /store_history -i ~/tf.hist ;;; Dump a world history for later restoring. /addworld store_history_ localhost echo /histsize -wstore_history_ 10 /def -i store_history =\ /let opt_i=%;\ /let opt_g=%;\ /let opt_w=%;\ /if (!getopts("igw:")) /break%;/endif%;\ /if (opt_i) /let from=-i%;\ /elseif (opt_g) /let from=-g%;\ /elseif (opt_w !~ "") /let from=-w%{opt_w}%;\ /else \ /echo \% store_history: requires -i, -g, or -w%;\ /break%;\ /endif%;\ /let where=%1%;\ /if (where =~ "") \ /echo \% store_history: requires a filename%;\ /break%;\ /endif%;\ /let old_time_format=%{time_format}%;\ /set time_format=@%;\ /log -wstore_history_ %{where}%;\ /quote -S /echo -wstore_history_ -- %{from} `/recall %{from} -t 0-%;\ /log -wstore_history_ off%;\ /set time_format=%{old_time_format} /def -i restore_history =\ /let where=$[filename({1})]%;\ /if (where =~ "") \ /echo \% restore_history: requires a filename%;\ /break%;\ /endif%;\ /echo \% Reloading history from %{where}.%;\ /quote -S /recordline !sed -e 's/^\\([^ ]*\\) \\[\\([0-9]*\\)]/\\1 -t\\2 --/' %{where} ;;; This version avoids sed, but is godawful slow. ;;; ie, above took 74 seconds to load about 100,000 lines ;;; and this version took 246 seconds on the same file. /def -i restore_history2 =\ /let where=$[filename({1})%;\ /if (where =~ "") \ /echo \% restore_history: requires a filename%;\ /break%;\ /endif%;\ /echo \% Reloading history from %{where}.%;\ /quote -S /restore_history2_ '%{where} /def -i restore_history2_ =\ /test regmatch("^(-[^ ]*) \\[([0-9]*)\\]", {*})%;\ /recordline %P1 -t%P2 -- %PR /undef restore_history2 /undef restore_history2_