zsh-workers
 help / color / mirror / code / Atom feed
* Remove history entries
@ 2008-10-12 21:22 Jörg Sommer
  2008-10-13  3:41 ` Bart Schaefer
  2008-10-14 11:26 ` Richard Hartmann
  0 siblings, 2 replies; 7+ messages in thread
From: Jörg Sommer @ 2008-10-12 21:22 UTC (permalink / raw)
  To: zsh-workers

Hi,

is it possible to remove history entries? I would like to remove commands
didn't exist, i.e. their exit code is 127, in the precmd function. Is
this possible?

precmd()
{
    if [[ $? -eq 127 ]]
    then
        history drop -1
    fi
}

Bye, Jörg.
-- 
Was man mühelos erreichen kann, ist gewöhnlich nicht der Mühe wert,
erreicht zu werden.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove history entries
  2008-10-12 21:22 Remove history entries Jörg Sommer
@ 2008-10-13  3:41 ` Bart Schaefer
  2008-10-13 22:16   ` Jörg Sommer
  2008-10-14 11:26 ` Richard Hartmann
  1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2008-10-13  3:41 UTC (permalink / raw)
  To: zsh-workers

On Oct 12,  9:22pm, ( Text in unknown character set UTF-8 not shown )  wrote:
} 
} is it possible to remove history entries?

Sadly, no.  I'd like to be able to do this myself, particularly when
e.g. testing zsh completion, to remove all the goofy command fragments
and repetitions of "more /tmp/zsh99999ls13; : ls abc" that leak into
the history.

About the only thing I can think of would be to play some games in
which preexec runs "fc -p" and precmd runs "fc -P ; print -s ...".
That gets complicated quickly, because you don't want to push the
stack if the command is going to refer to the current history.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove history entries
  2008-10-13  3:41 ` Bart Schaefer
@ 2008-10-13 22:16   ` Jörg Sommer
  0 siblings, 0 replies; 7+ messages in thread
From: Jörg Sommer @ 2008-10-13 22:16 UTC (permalink / raw)
  To: zsh-workers

Hallo Bart,

Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Oct 12,  9:22pm, ( Text in unknown character set UTF-8 not shown )  wrote:
>} 
>} is it possible to remove history entries?
>
> Sadly, no.  I'd like to be able to do this myself, particularly when
> e.g. testing zsh completion, to remove all the goofy command fragments
> and repetitions of "more /tmp/zsh99999ls13; : ls abc" that leak into
> the history.

BTW: I find the idea to put the line ‘$PAGE /tmp/zsh…’ really good! It's
very helpful.

Bye, Jörg.
-- 
But in the case of "git revert", it should be an ancestor (or the user
is just insane, in which case it doesn't matter - insane people can do
insane things)
Linus Torvalds <alpine.LFD.1.00.0801041031590.2811@woody.linux-foundation.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove history entries
  2008-10-12 21:22 Remove history entries Jörg Sommer
  2008-10-13  3:41 ` Bart Schaefer
@ 2008-10-14 11:26 ` Richard Hartmann
  2008-10-14 11:43   ` Peter Stephenson
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Hartmann @ 2008-10-14 11:26 UTC (permalink / raw)
  To: Jörg Sommer; +Cc: zsh-workers

2008/10/12 Jörg Sommer <joerg@alea.gnuu.de>:

> is it possible to remove history entries? I would like to remove commands
> didn't exist, i.e. their exit code is 127, in the precmd function. Is
> this possible?

Didn't PWS add a hook for this, recently? I can't find it anywhere, though.


Richard

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove history entries
  2008-10-14 11:26 ` Richard Hartmann
@ 2008-10-14 11:43   ` Peter Stephenson
  2008-10-14 11:48     ` Richard Hartmann
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 2008-10-14 11:43 UTC (permalink / raw)
  To: zsh-workers

On Tue, 14 Oct 2008 13:26:54 +0200
"Richard Hartmann" <richih.mailinglist@gmail.com> wrote:
> 2008/10/12 Jörg Sommer <joerg@alea.gnuu.de>:
> 
> > is it possible to remove history entries? I would like to remove commands
> > didn't exist, i.e. their exit code is 127, in the precmd function. Is
> > this possible?
> 
> Didn't PWS add a hook for this, recently? I can't find it anywhere, though.

zshaddhistory/zshaddhistory_functions: annoyingly, you can't use them for
quite this purpose.  You can veto adding history entries at the point
they're added, but that's before they're executed, so you don't have the
status.

It might be possible to force it to overwrite it, but I don't think that's
a simple change.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove history entries
  2008-10-14 11:43   ` Peter Stephenson
@ 2008-10-14 11:48     ` Richard Hartmann
  2008-10-14 12:07       ` Peter Stephenson
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Hartmann @ 2008-10-14 11:48 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Tue, Oct 14, 2008 at 13:43, Peter Stephenson <pws@csr.com> wrote:

> It might be possible to force it to overwrite it, but I don't think that's
> a simple change.

Can't you "just" move the hooks for these functions? And/or introduce
a new set?


Richard


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Remove history entries
  2008-10-14 11:48     ` Richard Hartmann
@ 2008-10-14 12:07       ` Peter Stephenson
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Stephenson @ 2008-10-14 12:07 UTC (permalink / raw)
  To: zsh-workers

"Richard Hartmann" wrote:
> On Tue, Oct 14, 2008 at 13:43, Peter Stephenson <pws@csr.com> wrote:
> 
> > It might be possible to force it to overwrite it, but I don't think that's
> > a simple change.
> 
> Can't you "just" move the hooks for these functions? And/or introduce
> a new set?

No, the hook has to run before the line is saved.  Delaying saving it
until other code has run breaks the current model for how history code
works.  In particular executing history commands within the executed but
unsaved command would be screwed up.  There may be a fix, but I don't
see an easy fix.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-10-14 12:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-12 21:22 Remove history entries Jörg Sommer
2008-10-13  3:41 ` Bart Schaefer
2008-10-13 22:16   ` Jörg Sommer
2008-10-14 11:26 ` Richard Hartmann
2008-10-14 11:43   ` Peter Stephenson
2008-10-14 11:48     ` Richard Hartmann
2008-10-14 12:07       ` Peter Stephenson

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).