zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh users" <zsh-users@sunsite.dk>
Subject: Re: Editing history stack during runtime?
Date: Mon, 03 Mar 2008 08:30:16 -0800	[thread overview]
Message-ID: <080303083016.ZM13911@torch.brasslantern.com> (raw)
In-Reply-To: <2d460de70803030425t4233caa9l57519aac0796d82a@mail.gmail.com>

On Mar 3,  1:25pm, Richard Hartmann wrote:
}
} On Sat, Mar 1, 2008 at 1:59 PM, Bart Schaefer <schaefer@brasslantern.com> 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
    )


      reply	other threads:[~2008-03-03 16:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-29  1:09 Richard Hartmann
2008-02-29 16:43 ` Bart Schaefer
2008-02-29 19:42   ` Richard Hartmann
2008-03-01  3:22     ` Bart Schaefer
2008-03-01 10:38       ` Richard Hartmann
2008-03-01 12:59         ` Bart Schaefer
2008-03-03 12:25           ` Richard Hartmann
2008-03-03 16:30             ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=080303083016.ZM13911@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).