diff --git a/plugins/bem/_bem b/plugins/bem/_bem new file mode 100644 index 000000000..dfdcfe7ac --- /dev/null +++ b/plugins/bem/_bem @@ -0,0 +1,42 @@ +###-begin-bem-completion-### +# +# bem command completion script +# +# Installation: bem completion >> ~/.bashrc (or ~/.zshrc) +# Or, maybe: bem completion > /usr/local/etc/bash_completion.d/bem +# + +COMP_WORDBREAKS=${COMP_WORDBREAKS/=/} +COMP_WORDBREAKS=${COMP_WORDBREAKS/@/} +export COMP_WORDBREAKS + +if complete &>/dev/null; then + _bem_completion () { + local si="$IFS" + IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \ + COMP_LINE="$COMP_LINE" \ + COMP_POINT="$COMP_POINT" \ + bem completion -- "${COMP_WORDS[@]}" \ + 2>/dev/null)) || return $? + IFS="$si" + } + complete -F _bem_completion bem +elif compctl &>/dev/null; then + _bem_completion () { + local cword line point words si + read -Ac words + read -cn cword + let cword-=1 + read -l line + read -ln point + si="$IFS" + IFS=$'\n' reply=($(COMP_CWORD="$cword" \ + COMP_LINE="$line" \ + COMP_POINT="$point" \ + bem completion -- "${words[@]}" \ + 2>/dev/null)) || return $? + IFS="$si" + } + compctl -K _bem_completion bem +fi +###-end-bem-completion-###