From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26541 invoked by alias); 25 Aug 2010 20:41:56 -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: 15328 Received: (qmail 9638 invoked from network); 25 Aug 2010 20:41:53 -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, T_TO_NO_BRKTS_FREEMAIL 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:content-type; bh=kMDgvzlr49uCuhkYf/ljuoEhB6k7jj3sSXGauYrpde0=; b=nd+xtJNE+UZgABmtc5iQoPcJsPboE+Jesp5YlClRteb32PLiPjk+s+6TxxOatoOUZ6 VVte0XVXgBYqY/zojFa4u3n/KomLLXn2JxEyfSZCTGfi/HhZ43M9NIPv2l1okigrIWbE ZjnxY4HjP2tmTZuC+t4SimicM4gaAfyyok/A0= 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 :content-type; b=ixDm+eC8zTeCtJK4VtdrGvcGHIg1PkKDvbnQ6FRMnljL2dIIzl97c1ZlilENVrKiJU zYa+nbQvNwiYU5JOWlEEe5N0xcaacBulMS1tjOmehnv9vQBDODJNpchD8rWAeyNnzGc3 PiBnbwIRVZNnqAUm9OSXDszbRJVIV/QOZole0= MIME-Version: 1.0 In-Reply-To: References: <20100825192608.GG11622@trustfood.org> Date: Wed, 25 Aug 2010 22:41:49 +0200 Message-ID: Subject: Re: do not write certain commands to history file From: Mikael Magnusson To: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 25 August 2010 22:36, Eric Smith wrote: > > -- > - Eric Smith > Mikael Magnusson said: >> On 25 August 2010 21:26, Eric Smith wrote: >> > Oh zsh seers, >> > >> > What is the way to match certain words in commands so that they >> > are not written to the history file (but might possibly remain in the >> > buffer history which does not worry me much)? >> > >> > (I saw a thread on history encryption, seems a bit heavy handed). >> >> Remaining in the history buffer and writing to the history file seems >> to be linked together. You can however use the zshaddhistory() >> function to exclude things based on shellcode. >> >> zshaddhistory() { >> [[ $1 != "display ~/pron/*" ]] >> } >> > > 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*) > ]] > } Just doing zshaddhistory() { [[ $1 != *foobar* ]] } should be enough. (and works for me). -- Mikael Magnusson