Skip to content

Instantly share code, notes, and snippets.

@MarcosBL
Created April 3, 2019 01:05
Show Gist options
  • Save MarcosBL/ab94b2e5e734102ca5f76fceb6c337e4 to your computer and use it in GitHub Desktop.
Save MarcosBL/ab94b2e5e734102ca5f76fceb6c337e4 to your computer and use it in GitHub Desktop.
Bash-only Laravel Artisan tab auto-complete

Add the provided code in ~/.bash_profile ( or similarly sourced file ) and you'll get artisan command tab completes on any project on your system:

_artisan()
{
    local arg="${COMP_LINE#php }"

    case "$arg" in
        artisan*)
            COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
            COMMANDS=`php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"`
            COMPREPLY=(`compgen -W "$COMMANDS" -- "${COMP_WORDS[COMP_CWORD]}"`)
            ;;
        *)
            COMPREPLY=( $(compgen -o default -- "${COMP_WORDS[COMP_CWORD]}") )
            ;;
        esac

    return 0
}
complete -F _artisan php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment