Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
_composer_scripts() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local scripts=$(composer run-script -l --no-ansi 2> /dev/null | awk '/^ +[a-z]+/ { print $1 }')
COMPREPLY=( $(compgen -W "${scripts}" -- ${cur}) )
return 0
}
complete -F _composer_scripts composer
@matt-allan
Copy link
Author

matt-allan commented May 12, 2017

This requires a newer version of bash completion but works correctly when the script name contains : i.e. test:unit:

_composer_scripts() {
    local cur
    _get_comp_words_by_ref -n : cur
    local scripts=$(composer run-script -l --no-ansi 2> /dev/null |  awk '/^ +[a-z]+/ { print $1 }')
    COMPREPLY=( $(compgen -W "${scripts}" -- ${cur}) )
    __ltrim_colon_completions "$cur"
    return 0
}

complete -F _composer_scripts composer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment