From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12804 invoked by alias); 25 Aug 2010 21:01:25 -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: 15330 Received: (qmail 3121 invoked from network); 25 Aug 2010 21:01:24 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.212.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=17UOqExvARWOknlGsb5VZWRETCn8cDzqLeMNEpFY4OM=; b=EfgGYAbWgBYrF67eCtVEskDXSkoH7vW2Rn2ppNpeRBTJip/0cfFQU9X9og5fmp6Pb1 hyfsocx/LtS4Z0btawYuS9w/ihMz5U3zzleleOJXGVexdCdQ06QVDReWOWZVA3Vs0z1n XJmWWJ59XZGerqGvYBAdE5sbb2/RV0rxeBb3I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=s1EG7kb+Erh45iY1CUHFVpHdeILVhGxYASefGdd6qGHhOvvYi/q7oRmJ9/LL9H5AhG BtcQdLpnmBg6g+VuqgynTHYG4fWC21oCj84Cxd54bXvXLiReRIe9fzX+jcXhUiiuwXlO r2IvPHE+L6XqdojL1bx0uxFpU7V3S9Lsdak5w= MIME-Version: 1.0 In-Reply-To: References: <20100825192608.GG11622@trustfood.org> Date: Wed, 25 Aug 2010 23:01:08 +0200 Message-ID: Subject: Re: do not write certain commands to history file From: Mikael Magnusson To: "Benjamin R. Haskell" Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 25 August 2010 22:55, Benjamin R. Haskell wrote: > 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*] )) What are you talking about? There's no $arg anywhere, and no arrays. zshaddhistory() is passed the entire command line in a single argument. -- Mikael Magnusson