From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21437 invoked by alias); 25 Aug 2010 20:36:36 -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: 15327 Received: (qmail 11727 invoked from network); 25 Aug 2010 20:36:33 -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: none (ns1.primenet.com.au: domain at trustfood.org does not designate permitted sender hosts) Date: Wed, 25 Aug 2010 22:36:30 +0200 From: Eric Smith To: zsh-users@zsh.org Subject: Re: do not write certain commands to history file Message-ID: Mail-Followup-To: zsh-users@zsh.org References: <20100825192608.GG11622@trustfood.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) -- - 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*) ]] }