Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Editing history stack during runtime?
- X-seq: zsh-users 12675
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh users" <zsh-users@xxxxxxxxxx>
- Subject: Re: Editing history stack during runtime?
- Date: Mon, 03 Mar 2008 08:30:16 -0800
- In-reply-to: <2d460de70803030425t4233caa9l57519aac0796d82a@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <2d460de70802281709n1847611cp6cb9a5273e212bae@xxxxxxxxxxxxxx> <080229084310.ZM17549@xxxxxxxxxxxxxxxxxxxxxx> <2d460de70802291142u4bdf7c94qa330ff9dad1324f0@xxxxxxxxxxxxxx> <080229192218.ZM18081@xxxxxxxxxxxxxxxxxxxxxx> <2d460de70803010238l5f221208q1bd0a090c9eca3a9@xxxxxxxxxxxxxx> <080301045937.ZM19496@xxxxxxxxxxxxxxxxxxxxxx> <2d460de70803030425t4233caa9l57519aac0796d82a@xxxxxxxxxxxxxx>
On Mar 3, 1:25pm, Richard Hartmann wrote:
}
} On Sat, Mar 1, 2008 at 1:59 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > "The history accumulated since I logged in" *includes* the history
} > read from the history file at shell startup.
}
} Hmm, now that I think about it, this _does_ make sense. Matter of fact,
} nothing else would. I will probably try and hack something together that
} uses a custom variable to store invocation time of the shell
Hmm. Actually you can get away with discarding all history entries with
history number <= than the original value of SAVEHIST (from *before* the
assignment SAVEHIST=$HISTSIZE in the edit_history function). Assuming
that you haven't changed SAVEHIST since the last time the history file
was written, of course -- if you change SAVEHIST a lot you'll have to do
more work to get the startup-time maximum history number.
It's not particularly easy to discard those entries, though. Probably
the best way is to put the "fc -W" in a subshell and truncate the history
there, like so:
(
# Needs recent-enough zsh to have HISTCMD
if ((HISTCMD > histcmd_at_startup))
then HISTSIZE=$((HISTCMD - histcmd_at_startup))
fi
fc -W
)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author