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

Re: combine/merge .history?

On Oct 13, 10:03am, Ray Andrews wrote:
} Can we do simple cut/copy/paste operations in the .histfile?

If you're using the EXTENDED_HISTORY option or features that rely on
that format like shared/incremental history -- which it appears from
your excerpt that you are -- then it's not entirely safe to edit the
history by hand.

I don't know of anything particular that will go wrong, especially if
you only change it while no shells are running to access it, but you
should not be surprised if the history state gets a little odd.

However, you have a somewhat different case here:  You have history
files in two different formats that you want to combine.  To do this
you'll have to be careful to edit all entries into a single format.

} the 'lead numbers' are so different:

In the first example ...

} 1390861257:0;mcedit lilo.conf
} 1390861320:0;lilo -C /boot/lilo.conf
} 1390861514:0;startxfce4
} 1390861527:0;modprobe nouveau

... those are timestamps [e.g. 1390861527 is Mon Jan 27 14:25:27 2014
(PST)] followed by durations in seconds that the command took to run
(which always record as zero when sharing history, see the new option

This example ...

}   1074* c Boot
}   1075* e zshrc
}   1076* A
}   1077* man pv

... doesn't look like anything zsh ever saved; those would appear to
just be line numbers.  When not using EXTENDED_HISTORY et al., zsh
saves the commands without any leading prefix.

Your best bet is probably to remove everything up to the first ";"
from each line of the file with the timestamps, remove everything
through "* " from each line of the other, then combine the two and
try to read them into a "zsh -f" with "fc -R" (set HISTSIZE large
enough first).  If that works as you wanted, repeat the "fc -R" in
a regular login shell and save with "fc -A".

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