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

Re: Preventing a single command from being saved in history

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'


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