Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: do not write certain commands to history file
- X-seq: zsh-users 15328
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: do not write certain commands to history file
- Date: Wed, 25 Aug 2010 22:41:49 +0200
- 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=
- In-reply-to: <mailbox-6437-1282767733-460593@pepper>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20100825192608.GG11622@xxxxxxxxxxxxx> <AANLkTimkMhrSeX6VpDBbMxO-VdMOr4n-0qsF==xBPjNd@xxxxxxxxxxxxxx> <mailbox-6437-1282767733-460593@pepper>
On 25 August 2010 22:36, Eric Smith <es@xxxxxxxxxxxx> wrote:
>
> --
> - Eric Smith
> Mikael Magnusson said:
>> On 25 August 2010 21:26, Eric Smith <es@xxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author