Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to keep HISTFILE variable untouched
On Thu, Aug 17, 2023 at 11:28 AM Budi <budikusasi@xxxxxxxxx> wrote:
>
> At the end of
>
> % history -p
>
> The HISTFILE variable is cleaned up
>
> So how to keep HISTFILE variable remain untouched on any case ?
You can invoke `history -pa` from a function, or pass $HISTFILE as an
argument. What you should do depends on what you are trying to
achieve. From the docs:
fc -p [ -a ] [ filename [ histsize [ savehistsize ] ] ]
`fc -p' pushes the current history list onto a stack and
switches to a new history list. If the -a option is also
specified, this history list will be automatically popped
when the current function scope is exited, which is a
much better solution than creating a trap function to
call `fc -P' manually. If no arguments are specified,
the history list is left empty, $HISTFILE is unset, and
$HISTSIZE & $SAVEHIST are set to their default values.
If one argument is given, $HISTFILE is set to that
filename, $HISTSIZE & $SAVEHIST are left unchanged, and
the history file is read in (if it exists) to initialize
the new list. If a second argument is specified,
$HISTSIZE & $SAVEHIST are instead set to the single
specified numeric value. Finally, if a third argument is
specified, $SAVEHIST is set to a separate value from
$HISTSIZE. You are free to change these environment
values for the new history list however you desire in
order to manipulate the new history list.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author