On Sun, Apr 18, 2021, 7:13 PM Ananth Chellappa <ananth...@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. >