From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh users" <zsh-users@sunsite.dk>
Subject: Re: Editing history stack during runtime?
Date: Fri, 29 Feb 2008 19:22:18 -0800 [thread overview]
Message-ID: <080229192218.ZM18081@torch.brasslantern.com> (raw)
In-Reply-To: <2d460de70802291142u4bdf7c94qa330ff9dad1324f0@mail.gmail.com>
On Feb 29, 8:42pm, Richard Hartmann wrote:
}
} I want to take the session history, i.e. what was typed since last login,
} and edit that. Then, I want whatever I save to replace the session
} history.
I have a vague recollection of something like this having been posted
before, but not since we added "always" blocks and similar fun, so:
edit_hist () {
emulate -LR zsh
unsetopt append_history inc_append_history share_history
# You may want these in this case even if not otherwise:
# setopt hist_expire_dups_first hist_ignore_all_dups
# The following gibberish creates a unique tempfile
# and makes sure that we'll write the whole history
local SAVEHIST=$HISTSIZE HISTFILE=${:-=(:)}$$
# Make sure we write a new file and rename to the tempfile
setopt no_hist_save_by_copy
# Finally, the actual useful work
fc -W
{
if ${VISUAL:-${EDITOR:-vi}} $HISTFILE
then
# Truncate internal history to discard deleted lines
HISTSIZE=0
HISTSIZE=$SAVEHIST
fc -R
fi
} always {
rm -f $HISTFILE
}
}
next prev parent reply other threads:[~2008-03-01 3:23 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 [this message]
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
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=080229192218.ZM18081@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).