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

Re: trivial problem with histverify

On Dec 1,  4:10pm, Ray Andrews wrote:
} I'm guessing that the code that handles 'histverify' sees the " !! "
} and so demands the ENTER, but I'd say that in this situation

You're misinterpreting histverify.

It is not intended to verify that "a history command is actually being
executed."  It is intended to verify that in the text of any command in
which history was referenced, the correct history reference was made.

For example, suppose you typed

% rm -f !:4

(remove the file named by the fourth argument of the previous command).
Histverify allows you to see which file name is going to be removed
before it actually is removed.

} shouldn't be required since no history command is actually being 
} executed, it's just a listing of string matches.

You're giving the shell way too much credit for "knowing" what the
effects of the command are going to be.  You might have a command in
$HOME/bin named "grep" for "gamma radiation exposure percentage" or
"get rid of everyone please."

} wondering if there's a workaround, so that my binding is exempt

Don't use "!!" in the binding?

Honestly, how did it ever get that complicated?  Why print -s the words
into the history and then pull them back out again with "!!" rather
than just:

bindkey -s '\e[5~' '\C-a history 1 | grep "[[:digit:]]  \C-e"\C-m'

??  Which of course breaks if there are any double quotes in what you
typed before pressing page-up, but that was already the case.

} BTBTW it seems a strange way to

} could find that worked at the time.

This is a case where you should be writing a user-defined widget rather
than using "bindkey -s".

    grep-history() {
      (( HISTNO > 1 )) || return
      zle -I
      history 1 | grep --color=auto "[[:digit:]]  $BUFFER"
    zle -N grep-history
    bindkey '\e[5~' grep-history


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