zsh-users
 help / color / mirror / code / Atom feed
* Preventing a single command from being saved in history
@ 2009-02-18 16:19 Allan Caffee
  2009-02-18 16:25 ` Mikael Magnusson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Allan Caffee @ 2009-02-18 16:19 UTC (permalink / raw)
  To: zsh-users

Is there a way to prevent an arbitrary command line from being stored in
the shell history (for any longer than one command)?  A use of this for
example might be if I were to set a password into the environment or
pass some sensitive information to a program on the command line.

If this functionality does not currently exist how difficult would it be
to provide a precommand modifier?  I know the internals for this kind of
manipulation are already in place for options like HistNoStore and
HistNoFunctions. I've only glanced over the source code but it seems
like all that would be needed is to have should_ignore_line return 1 if
the precommand modifier is in effect.

        Regards,
        Allan

P.S. Yes. I'm well aware of how insecure putting sensitive information
into the environment or on a command line is. Consider your obligation
to warn me hereby fulfilled. :P


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Preventing a single command from being saved in history
  2009-02-18 16:19 Preventing a single command from being saved in history Allan Caffee
@ 2009-02-18 16:25 ` Mikael Magnusson
  2009-02-18 16:27 ` Matt Wozniski
  2009-02-18 16:31 ` Benjamin R. Haskell
  2 siblings, 0 replies; 4+ messages in thread
From: Mikael Magnusson @ 2009-02-18 16:25 UTC (permalink / raw)
  To: Allan Caffee; +Cc: zsh-users

2009/2/18 Allan Caffee <allan.caffee@gmail.com>:
> Is there a way to prevent an arbitrary command line from being stored in
> the shell history (for any longer than one command)?  A use of this for
> example might be if I were to set a password into the environment or
> pass some sensitive information to a program on the command line.
>
> If this functionality does not currently exist how difficult would it be
> to provide a precommand modifier?  I know the internals for this kind of
> manipulation are already in place for options like HistNoStore and
> HistNoFunctions. I've only glanced over the source code but it seems
> like all that would be needed is to have should_ignore_line return 1 if
> the precommand modifier is in effect.
>
>        Regards,
>        Allan
>
> P.S. Yes. I'm well aware of how insecure putting sensitive information
> into the environment or on a command line is. Consider your obligation
> to warn me hereby fulfilled. :P

Just type a leading space and the command won't be saved. You can
retreive it with up-arrow until another command is run (ie just
pressing enter again won't remove it). You also need to setopt
histignorespace for this to work.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Preventing a single command from being saved in history
  2009-02-18 16:19 Preventing a single command from being saved in history Allan Caffee
  2009-02-18 16:25 ` Mikael Magnusson
@ 2009-02-18 16:27 ` Matt Wozniski
  2009-02-18 16:31 ` Benjamin R. Haskell
  2 siblings, 0 replies; 4+ messages in thread
From: Matt Wozniski @ 2009-02-18 16:27 UTC (permalink / raw)
  To: zsh-users

On Wed, Feb 18, 2009 at 11:19 AM, Allan Caffee wrote:
> Is there a way to prevent an arbitrary command line from being stored in
> the shell history (for any longer than one command)?  A use of this for
> example might be if I were to set a password into the environment or
> pass some sensitive information to a program on the command line.

See the help on the zshaddhistory function in the SPECIAL FUNCTIONS
section of the manual.

~Matt


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Preventing a single command from being saved in history
  2009-02-18 16:19 Preventing a single command from being saved in history Allan Caffee
  2009-02-18 16:25 ` Mikael Magnusson
  2009-02-18 16:27 ` Matt Wozniski
@ 2009-02-18 16:31 ` Benjamin R. Haskell
  2 siblings, 0 replies; 4+ messages in thread
From: Benjamin R. Haskell @ 2009-02-18 16:31 UTC (permalink / raw)
  To: Zsh Users

On Wed, 18 Feb 2009, Allan Caffee wrote:

> Is there a way to prevent an arbitrary command line from being stored in 
> the shell history (for any longer than one command)?  A use of this for 
> example might be if I were to set a password into the environment or 
> pass some sensitive information to a program on the command line.
>
> If this functionality does not currently exist how difficult would it be 
> to provide a precommand modifier?  I know the internals for this kind of 
> manipulation are already in place for options like HistNoStore and 
> HistNoFunctions. I've only glanced over the source code but it seems 
> like all that would be needed is to have should_ignore_line return 1 if 
> the precommand modifier is in effect.

I assume you're looking for histignorespace (hist_ignore_space if you're 
rooting through man pages)?  Then any command that starts with a space (or 
any alias that expands as such) is ignored.

The 'alias' thing is useful, for example, to hide some things I don't 
really care to have in history:

alias fg=' builtin fg'
alias bg=' builtin bg'
alias rehash=' builtin rehash'

Best,
Ben


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-18 16:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-18 16:19 Preventing a single command from being saved in history Allan Caffee
2009-02-18 16:25 ` Mikael Magnusson
2009-02-18 16:27 ` Matt Wozniski
2009-02-18 16:31 ` Benjamin R. Haskell

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).