From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-users@zsh.org
Subject: Re: do not write certain commands to history file
Date: Wed, 25 Aug 2010 22:41:49 +0200 [thread overview]
Message-ID: <AANLkTinAY6APp8LkUapXmzB6YGN2VAtq4LMFdsmgzTXZ@mail.gmail.com> (raw)
In-Reply-To: <mailbox-6437-1282767733-460593@pepper>
On 25 August 2010 22:36, Eric Smith <es@fruitcom.com> wrote:
>
> --
> - Eric Smith
> Mikael Magnusson said:
>> On 25 August 2010 21:26, Eric Smith <es@fruitcom.com> 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
next prev parent reply other threads:[~2010-08-25 20:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-25 19:26 Eric Smith
2010-08-25 19:46 ` Mikael Magnusson
2010-08-25 20:36 ` Eric Smith
2010-08-25 20:41 ` Mikael Magnusson [this message]
2010-08-25 20:55 ` Benjamin R. Haskell
2010-08-25 21:01 ` Mikael Magnusson
2010-08-25 21:11 ` Benjamin R. Haskell
2010-08-25 21:01 ` do not write certain commands to history file - solved Eric Smith
2010-08-26 8:10 ` do not write certain commands to history file Sebastian Stark
2010-08-26 8:28 ` Sebastian Stark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinAY6APp8LkUapXmzB6YGN2VAtq4LMFdsmgzTXZ@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).