* Hiding command from history
@ 2015-02-03 11:29 İsmail Dönmez
2015-02-03 12:13 ` Peter Stephenson
0 siblings, 1 reply; 11+ messages in thread
From: İsmail Dönmez @ 2015-02-03 11:29 UTC (permalink / raw)
To: Zsh Users
Hi,
I know I can set HIST_IGNORE_SPACE and any command starting with space
will not be logged in history. But with that I have many aliases like
alias ls=" ls"
alias mv=" mv"
etc. So, I wonder if there is an easier way to blacklist multiple
commands from history without creating an alias for each of them?
Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 11:29 Hiding command from history İsmail Dönmez
@ 2015-02-03 12:13 ` Peter Stephenson
2015-02-03 12:34 ` İsmail Dönmez
2015-02-03 12:37 ` Peter Stephenson
0 siblings, 2 replies; 11+ messages in thread
From: Peter Stephenson @ 2015-02-03 12:13 UTC (permalink / raw)
To: Zsh Users
On Tue, 3 Feb 2015 13:29:34 +0200
İsmail Dönmez <ismail@donmez.ws> wrote:
> Hi,
>
> I know I can set HIST_IGNORE_SPACE and any command starting with space
> will not be logged in history. But with that I have many aliases like
>
> alias ls=" ls"
> alias mv=" mv"
>
> etc. So, I wonder if there is an easier way to blacklist multiple
> commands from history without creating an alias for each of them?
Have a look at HISTORY_IGNORE in the zshparam manule, and if you want
something a bit more powerful also the zshaddhistory hook in the zshmisc
manuel (and let us know if that doesn't seem to make sense...)
pws
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 12:13 ` Peter Stephenson
@ 2015-02-03 12:34 ` İsmail Dönmez
2015-02-03 12:47 ` Peter Stephenson
2015-02-03 12:37 ` Peter Stephenson
1 sibling, 1 reply; 11+ messages in thread
From: İsmail Dönmez @ 2015-02-03 12:34 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh Users
Hi,
On Tue, Feb 3, 2015 at 2:13 PM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Tue, 3 Feb 2015 13:29:34 +0200
> İsmail Dönmez <ismail@donmez.ws> wrote:
>> Hi,
>>
>> I know I can set HIST_IGNORE_SPACE and any command starting with space
>> will not be logged in history. But with that I have many aliases like
>>
>> alias ls=" ls"
>> alias mv=" mv"
>>
>> etc. So, I wonder if there is an easier way to blacklist multiple
>> commands from history without creating an alias for each of them?
>
> Have a look at HISTORY_IGNORE in the zshparam manule
This seems to be the best option but I can't figure out the syntaxt.
Bash's similar HISTIGNORE syntax
HISTORY_IGNORE="rm *:ls *"
doesn't seem to work. Tried with
> HISTORY_IGNORE="rm *:ls *" zsh
Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 12:34 ` İsmail Dönmez
@ 2015-02-03 12:47 ` Peter Stephenson
2015-02-03 13:06 ` İsmail Dönmez
0 siblings, 1 reply; 11+ messages in thread
From: Peter Stephenson @ 2015-02-03 12:47 UTC (permalink / raw)
To: Zsh Users
On Tue, 3 Feb 2015 14:34:49 +0200
İsmail Dönmez <ismail@donmez.ws> wrote:
> On Tue, Feb 3, 2015 at 2:13 PM, Peter Stephenson
> <p.stephenson@samsung.com> wrote:
> > On Tue, 3 Feb 2015 13:29:34 +0200
> > İsmail Dönmez <ismail@donmez.ws> wrote:
> >> I know I can set HIST_IGNORE_SPACE and any command starting with space
> >> will not be logged in history. But with that I have many aliases like
> >>
> >> alias ls=" ls"
> >> alias mv=" mv"
> >>
> >> etc. So, I wonder if there is an easier way to blacklist multiple
> >> commands from history without creating an alias for each of them?
> >
> > Have a look at HISTORY_IGNORE in the zshparam manule
>
> This seems to be the best option but I can't figure out the syntaxt.
> Bash's similar HISTIGNORE syntax
>
> HISTORY_IGNORE="rm *:ls *"
>
> doesn't seem to work. Tried with
>
> > HISTORY_IGNORE="rm *:ls *" zsh
HISTORY_IGNORE just stops things being written to history files;
I don't think that's quite you want. If it was, it's a single pattern,
so you should be able to do
HISTORY_IGNORE="(rm|ls) *"
You can do this, though:
zshaddhistory() { [[ $1 = (ls|rm)\ * ]] && return 1; }
and indeed there's no reason I can think of why you couldn't simply
define
zshaddhistory() { [[ $1 = ${~HISTORY_IGNORE} ]] && return 1; }
pws
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 12:47 ` Peter Stephenson
@ 2015-02-03 13:06 ` İsmail Dönmez
2015-02-03 13:49 ` İsmail Dönmez
0 siblings, 1 reply; 11+ messages in thread
From: İsmail Dönmez @ 2015-02-03 13:06 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh Users
On Tue, Feb 3, 2015 at 2:47 PM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> and indeed there's no reason I can think of why you couldn't simply
> define
>
> zshaddhistory() { [[ $1 = ${~HISTORY_IGNORE} ]] && return 1; }
This is quite nice. Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 13:06 ` İsmail Dönmez
@ 2015-02-03 13:49 ` İsmail Dönmez
2015-02-03 14:02 ` Peter Stephenson
0 siblings, 1 reply; 11+ messages in thread
From: İsmail Dönmez @ 2015-02-03 13:49 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh Users
On Tue, Feb 3, 2015 at 3:06 PM, İsmail Dönmez <ismail@donmez.ws> wrote:
> On Tue, Feb 3, 2015 at 2:47 PM, Peter Stephenson
> <p.stephenson@samsung.com> wrote:
>> and indeed there's no reason I can think of why you couldn't simply
>> define
>>
>> zshaddhistory() { [[ $1 = ${~HISTORY_IGNORE} ]] && return 1; }
>
> This is quite nice. Thanks!
Talked too early it seems. When I add this line to my ~/.zshrc then
history file is never updated when I exit the shell. Removing this
line fixes the problem. Any ideas why? I also tried the
zshaddhistory() { [[ $1 = (ls|rm)\ * ]] && return 1; }
version but the same problem happens there. I am using zsh.git
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 13:49 ` İsmail Dönmez
@ 2015-02-03 14:02 ` Peter Stephenson
2015-02-03 14:07 ` İsmail Dönmez
2015-02-03 16:39 ` Peter Stephenson
0 siblings, 2 replies; 11+ messages in thread
From: Peter Stephenson @ 2015-02-03 14:02 UTC (permalink / raw)
To: Zsh Users
On Tue, 3 Feb 2015 15:49:20 +0200
İsmail Dönmez <ismail@donmez.ws> wrote:
> On Tue, Feb 3, 2015 at 3:06 PM, İsmail Dönmez <ismail@donmez.ws> wrote:
> > On Tue, Feb 3, 2015 at 2:47 PM, Peter Stephenson
> > <p.stephenson@samsung.com> wrote:
> >> and indeed there's no reason I can think of why you couldn't simply
> >> define
> >>
> >> zshaddhistory() { [[ $1 = ${~HISTORY_IGNORE} ]] && return 1; }
> >
> > This is quite nice. Thanks!
>
> Talked too early it seems. When I add this line to my ~/.zshrc then
> history file is never updated when I exit the shell. Removing this
> line fixes the problem. Any ideas why?
Sorry, I was careless with status. Which just goes to show...
See if the following works, which I think it does...
zshaddhistory() { [[ $1 != ${~HISTORY_IGNORE} ]]; }
The old one reflected the status of the [[ ... ]] if it failed, but the
status of that is actually all we need as long as we reverse it.
pws
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 14:02 ` Peter Stephenson
@ 2015-02-03 14:07 ` İsmail Dönmez
2015-02-03 16:39 ` Peter Stephenson
1 sibling, 0 replies; 11+ messages in thread
From: İsmail Dönmez @ 2015-02-03 14:07 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh Users
Hi,
On Tue, Feb 3, 2015 at 4:02 PM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Tue, 3 Feb 2015 15:49:20 +0200
> İsmail Dönmez <ismail@donmez.ws> wrote:
>
>> On Tue, Feb 3, 2015 at 3:06 PM, İsmail Dönmez <ismail@donmez.ws> wrote:
>> > On Tue, Feb 3, 2015 at 2:47 PM, Peter Stephenson
>> > <p.stephenson@samsung.com> wrote:
>> >> and indeed there's no reason I can think of why you couldn't simply
>> >> define
>> >>
>> >> zshaddhistory() { [[ $1 = ${~HISTORY_IGNORE} ]] && return 1; }
>> >
>> > This is quite nice. Thanks!
>>
>> Talked too early it seems. When I add this line to my ~/.zshrc then
>> history file is never updated when I exit the shell. Removing this
>> line fixes the problem. Any ideas why?
>
> Sorry, I was careless with status. Which just goes to show...
>
> See if the following works, which I think it does...
>
> zshaddhistory() { [[ $1 != ${~HISTORY_IGNORE} ]]; }
That works as expected, thanks again!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 14:02 ` Peter Stephenson
2015-02-03 14:07 ` İsmail Dönmez
@ 2015-02-03 16:39 ` Peter Stephenson
1 sibling, 0 replies; 11+ messages in thread
From: Peter Stephenson @ 2015-02-03 16:39 UTC (permalink / raw)
To: Zsh Users
On Tue, 3 Feb 2015 14:02:42 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> zshaddhistory() { [[ $1 != ${~HISTORY_IGNORE} ]]; }
Worth mentioning.
pws
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 391a5fb..ee7c054 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1052,10 +1052,25 @@ item(tt(HISTORY_IGNORE))(
If set, is treated as a pattern at the time history files are written.
Any potential history entry that matches the pattern is skipped. For
example, if the value is `tt(fc *)' then commands that invoke the
-interactive history editor are never written to the history file (compare
-the tt(HIST_NO_STORE) option or the tt(zshaddhistory) hook, either of
-which would prevent such commands from being added to the interactive
-history at all).
+interactive history editor are never written to the history file.
+
+Note that tt(HISTORY_IGNORE) defines a single pattern: to
+specify alternatives use the `tt(+LPAR()first|second|...+RPAR())'
+syntax.
+
+Compare the tt(HIST_NO_STORE) option or the tt(zshaddhistory) hook,
+either of which would prevent such commands from being added to the
+interactive history at all. If you wish to use tt(HISTORY_IGNORE) to
+stop history being added in the first place, you can define the
+following hook:
+
+example(zshaddhistory+LPAR()RPAR() {
+ emulate -L zsh
+ ## uncomment if HISTORY_IGNORE
+ ## should use EXTENDED_GLOB syntax
+ # setopt extendedglob
+ [[ $1 != ${~HISTORY_IGNORE} ]]
+})
)
vindex(HISTSIZE)
item(tt(HISTSIZE) <S>)(
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Hiding command from history
2015-02-03 12:13 ` Peter Stephenson
2015-02-03 12:34 ` İsmail Dönmez
@ 2015-02-03 12:37 ` Peter Stephenson
2015-02-04 17:35 ` Bart Schaefer
1 sibling, 1 reply; 11+ messages in thread
From: Peter Stephenson @ 2015-02-03 12:37 UTC (permalink / raw)
To: Zsh Users
On Tue, 3 Feb 2015 12:13:49 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> Have a look at HISTORY_IGNORE in the zshparam manule, and if you want
> something a bit more powerful also the zshaddhistory hook in the zshmisc
> manuel (and let us know if that doesn't seem to make sense...)
Hey, I misspelled manual twice in two different ways.
Pretend I didn't.
pws
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-02-04 17:35 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-03 11:29 Hiding command from history İsmail Dönmez
2015-02-03 12:13 ` Peter Stephenson
2015-02-03 12:34 ` İsmail Dönmez
2015-02-03 12:47 ` Peter Stephenson
2015-02-03 13:06 ` İsmail Dönmez
2015-02-03 13:49 ` İsmail Dönmez
2015-02-03 14:02 ` Peter Stephenson
2015-02-03 14:07 ` İsmail Dönmez
2015-02-03 16:39 ` Peter Stephenson
2015-02-03 12:37 ` Peter Stephenson
2015-02-04 17:35 ` Bart Schaefer
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).