From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29621 invoked by alias); 25 Aug 2010 20:55:38 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15329 Received: (qmail 28409 invoked from network); 25 Aug 2010 20:55:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Wed, 25 Aug 2010 16:55:04 -0400 (EDT) From: "Benjamin R. Haskell" To: zsh-users@zsh.org Subject: Re: do not write certain commands to history file In-Reply-To: Message-ID: References: <20100825192608.GG11622@trustfood.org> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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