From: "Benjamin R. Haskell" <zsh@benizi.com>
To: zsh-users@zsh.org
Subject: Re: do not write certain commands to history file
Date: Wed, 25 Aug 2010 16:55:04 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1008251647000.4535@hp> (raw)
In-Reply-To: <mailbox-6437-1282767733-460593@pepper>
On Wed, 25 Aug 2010, Eric Smith wrote:
> Thanks Mikael. If it is not in the buffer I do not care. But I cannot
> work your example.
>
> Found this below in a config file somewhere and thought I could adapt
> it. I want to exclude all commands that have "foobar" anywhere in
> them, as the command or in the arg list. Quick hack did not work.
> All lines are still written to the history file.
>
> zshaddhistory() {
> local line=${1%%$'\n'}
> local cmd=${line%% *}
>
> [[ ${#line} -ge 5
> && ${cmd} != "rm"
> && ${cmd} != (l|l[sal])
> && ${cmd} != (c|cd)
> && ${cmd} != (m|man)
> && ${arg} != (*foobar*)
> ]]
> }
Where are you setting $arg? Do you mean $line? or are you trying to
match *foobar* in $argv?
If the latter, you can't just match an array against a pattern (since
there's no sensible default for whether it's conjunctive or disjunctive
[any or all]). I'm not sure of the [[ ]] form offhand, but the (( ))
form would be:
[[ # what you already have ]] && (( ! $argv[(I)*foobar*] ))
--
Best,
Ben
next prev parent reply other threads:[~2010-08-25 20:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-25 19:26 Eric Smith
2010-08-25 19:46 ` Mikael Magnusson
2010-08-25 20:36 ` Eric Smith
2010-08-25 20:41 ` Mikael Magnusson
2010-08-25 20:55 ` Benjamin R. Haskell [this message]
2010-08-25 21:01 ` Mikael Magnusson
2010-08-25 21:11 ` Benjamin R. Haskell
2010-08-25 21:01 ` do not write certain commands to history file - solved Eric Smith
2010-08-26 8:10 ` do not write certain commands to history file Sebastian Stark
2010-08-26 8:28 ` Sebastian Stark
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=alpine.LNX.2.01.1008251647000.4535@hp \
--to=zsh@benizi.com \
--cc=zsh-users@zsh.org \
/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).