Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Append cancelled commands to history
- X-seq: zsh-users 14955
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Append cancelled commands to history
- Date: Mon, 22 Mar 2010 08:07:11 -0700
- In-reply-to: <20100322084226.GA26739@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <c16a574a0809181450t61a5b5ddq2e80797fde37636e@xxxxxxxxxxxxxx> <20080919162045.GA22435@xxxxxxxxxxxx> <20090706151644.6BF508027106@xxxxxxxxxxxxxxxxxx> <20090706154309.GA15663@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20090706155337.GB15663@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20100315164237.GA23224@xxxxxxxxxxxxxxxxxxxxxxxxxx> <100320105027.ZM20067@xxxxxxxxxxxxxxxxxxxxxx> <20100322084226.GA26739@xxxxxxxxxxxxxxxxxxxxxxxxxx>
On Mar 22, 10:42am, Nadav Har'El wrote:
> Subject: Re: Append cancelled commands to history
>
> But the problem I have now is that when I now go up in the history, the
> last command I see is
>
> for i in *
> do
>
> which is what standard zsh saved - without the last partial line - and when I
> go up another command in history I see
>
> for i in *
> do
> echo
>
> which is what my code saved. I wished there was a way not to save that
> shorter version, with only the accepted lines.
Something like this may work:
typeset -g INTBUFFER
autoload -U add-zsh-hook
trapint_history() {
if [[ -n "$INTBUFFER" ]]
then
print -s -r -- "$INTBUFFER"
INTBUFFER=
return 1
fi
return 0
}
TRAPINT() {
zle && [[ $HISTNO -eq $HISTCMD ]] && INTBUFFER="$PREBUFFER$BUFFER"
return $1
}
add-zsh-hook zshaddhistory trapint_history
--
Messages sorted by:
Reverse Date,
Date,
Thread,
Author