bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: enhancement merge request


From: Ananth Chellappa
Subject: Re: enhancement merge request
Date: Sun, 18 Apr 2021 22:31:22 -0700

Thanks. Rube Goldberg would approve🙂

On Sun, Apr 18, 2021 at 10:17 PM Grisha Levit <grishalevit@gmail.com> wrote:

> On Sun, Apr 18, 2021, 7:13 PM Ananth Chellappa <ananth.ch@gmail.com>
> wrote:
>
>> Far as I understand, there is no
>> way to accomplish what I want - concisely : *get a true private mode* (no
>> logging to HISTFILE *OR* recall with history command after exiting
>> private-mode (toggle of history using set -/+ o) *without sacrificing
>> productivity*.
>>
>
> I think you can do something similar to the patch directly in the shell by
> temporarily unsetting HISTFILE and then deleting history entries in a
> certain range and restoring HISTFILE when you are ready, like:
>
> hist_pause() {
>     [[ -z ${pause_histcmd-} ]] || return
>     pause_histcmd=$HISTCMD
>     old_histfile=$HISTFILE
>     history -a # in case we exit w/o hist_resume
>     HISTFILE=
> }
> hist_resume() {
>     [[ -n ${pause_histcmd-} ]] || return
>     local i
>     for ((i=HISTCMD; i>pause_histcmd; i--)); do
>         history -d $i
>     done
>     unset pause_histcmd
>     HISTFILE=$old_histfile
> }
>
> Or, alternatively, unset HISTFILE, write out the current history to a
> temporary file (`history -w $file') and then later clear the history
> (`history -c'), read in the temporary file (`history -r $file'), and
> restore HISTFILE.
>
> The latter approach might be slightly more robust but, note that the
> history list will be re-numbered to start at 1 after restoring.
>
>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]