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

Re: Conditionally complete on space.



On 08/18/2017 11:13 AM, Grant Taylor wrote:
Thanks to your help Daniel, I believe I have something that I can start using and deal with any annoyances as they come up. :-)

As sure as I sent the email, I stubbed my toe on something else.

"ipc" expands to ipcalc ipcmk ipcrm ipcs. Adding "a" and hitting space would not complete ipcalc with my last script

Slightly tweaking things does:

maybe-expand-or-complete() {
	if [[ $LBUFFER[-1] != ' ' && "$JUSTCOMPLETED" != $LBUFFER ]]; then
		zle expand-or-complete
		if [[ $LBUFFER[-1] != ' ' ]]; then
			JUSTCOMPLETED=$LBUFFER
		fi
	else
		unset JUSTCOMPLETED
		zle self-insert
	fi
}
zle -N maybe-expand-or-complete
bindkey ' ' maybe-expand-or-complete
setopt recexact

This version checks to see if the last completion matches the current line buffer. If they differ, expand-or-complete.

Thank you again Daniel.



--
Grant. . . .
unix || die

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



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