Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Preventing a single command from being saved in history



2009/2/18 Allan Caffee <allan.caffee@xxxxxxxxx>:
> 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



Messages sorted by: Reverse Date, Date, Thread, Author