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

Re: Makeing history harmless



On 2006-10-12 at 04:47 +0200, Meino Christian Cramer wrote:
>  Is it possible to write a "something" to filter out certain commands 
>  or to modify certain commands before they were copied from the
>  commandline into the history ?

(1) setopt hist_ignore_space
    Then get used to typing a space at the start of the line of
    dangerous commands.  The item remains in the history only until the
    next command is run.

(2) Combine that option with a new accept-line to apply it automatically

-----------------------------< cut here >-------------------------------
setopt hist_ignore_space

function histfilter-accept-line {
  emulate -L zsh
  case ${${(z)BUFFER}[1]} in
  (rm|rmdir) BUFFER=" $BUFFER" ;;
  esac
  zle .accept-line
}

zle -N histfilter-accept-line
zle -A histfilter-accept-line accept-line
-----------------------------< cut here >-------------------------------

Regards,
-Phil



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