Skip to content

Instantly share code, notes, and snippets.

@jhoff
Last active April 1, 2024 07:45
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save jhoff/8fbe4116d74931751ecc9e8203dfb7c4 to your computer and use it in GitHub Desktop.
Save jhoff/8fbe4116d74931751ecc9e8203dfb7c4 to your computer and use it in GitHub Desktop.
Bash-only Laravel Artisan tab auto-complete

If you are an Oh-my-zsh user, see the Laravel 5 plugin

For the rest of us Bash users, all of the Laravel Artisan autocomplete solutions out there require installing a composer package to get a list of artisan commands. Turns out this isn't really necessary. Simply 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()
{
	COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
	COMMANDS=`php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"`
	COMPREPLY=(`compgen -W "$COMMANDS" -- "${COMP_WORDS[COMP_CWORD]}"`)
	return 0
}
complete -F _artisan art
complete -F _artisan artisan
@zahardev
Copy link

zahardev commented Jan 6, 2024

@sfinktah Thank you, it should be in the Laravel/Sail docs!

@sfinktah
Copy link

sfinktah commented Apr 1, 2024

@zahardev
@taylorotwell

Thanks! But I can't even get permission to contribute to the Laravel Nova repo, and I'm a paid subscriber.

P.S. @matthiasl Euphoria BBS?

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