Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Makeing history harmless
- X-seq: zsh-users 10847
- From: Chris Johnson <cjohnson@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Makeing history harmless
- Date: Thu, 12 Oct 2006 09:15:21 -0400
- In-reply-to: <20061012050911.GA4764@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20061012.044715.74744338.Meino.Cramer@xxxxxx> <20061012050911.GA4764@xxxxxxxxxxxxxxxxxxxxx>
Phil Pennock sent me the following 0.9K:
> 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.
It took me a bit to catch on to the fact that the most recently executed
line is always in the history.
> (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 >-------------------------------
I do this with:
setopt hist_ignore_space
alias rm=' rm'
Is there an advantage to using the widget?
--
Chris Johnson
cjohnson@xxxxxxxxxx
http://www.cs.utk.edu/~cjohnson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author