Re: manually truncating histfile?
Bart Schaefer <[email protected]>
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAH+w=7YtZ7tah3ggYWB=MO3F+OGtggKV17w=GtMkpV9Bvu3PQw@mail.gmail.com> |
On Sat, Dec 28, 2024 at 10:06 AM 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? Something like this, I think: truncate_histfile () { local SAVEHIST=0 fc -W } This has to be run in an interactive shell. Alternately, to just write out the current shell history: save_this_history () { local SAVEHIST=$HISTSIZE fc -W } Might require addition of some "setopt localoptions ..." to change the state of history sharing/appending depending on what you enable and what you want the resulting behavior to be.