Re: manually truncating histfile?

Jim <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <CA+rB6G+etqo-vYZqNxn2-60BKZdZm1_tZ_GzR_utBjFHmbGDRQ@mail.gmail.com>
On Sat, Dec 28, 2024 at 12:06 PM Anthony Heading <[email protected]> wrote:

> I have SAVEHIST=0x4000000 to prevent the history file ever being
> automatically truncated before e.g. I can archive it.
>
> What's the best way then to explicitly truncate?  If I run a
> (non-interactive?) shell script with SAVEHIST set to a lower value, I'm not
> sure what triggers a rewrite.   Alternatively I could flock the histfile
> and do it manually, but I'm also not sure if flock is the appropriate lock
> on all platforms.
>
> From the manual:

   "Note that it's currently only possible to read and write files saving
    history when the shell is interactive, i.e. it does not work from
scripts."

If I'm reading this correctly, shell scripts shouldn't be an issue.

Jim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.