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

Re: make history-complete-older do nothing on empty string



 ❦ 18 avril 2018 09:11 -0700, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> :

> You'd want a wrapper around _history_complete_word to check the state
> of the editor buffer, or you could copy that function to a location at
> the front of your $fpath and modify it.  The test you want is probably
> something like:
>
> [[ ${LBUFFER:- } == ' ' && ${RBUFFER:- } == ' ' ]] && return 1
>
> There's a space after :- in both of those references.  This means "if
> either the buffer is empty or the cursor is sitting in the middle of a
> run of spaces, then return" (i.e. don't complete anything).

Thanks, I am using this and it works as I would expect:

#v+
# Don't do history completion on empty words
function vbe-history-complete-older() {
  [[ ${LBUFFER[-1]} == ' ' || ${LBUFFER} == '' ]] && return 1
  zle _history-complete-older "$@"
}
zle -N vbe-history-complete-older
bindkey "^[/" vbe-history-complete-older
#v-

-- 
Harp not on that string.
		-- William Shakespeare, "Henry VI"



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