Skip to content

Instantly share code, notes, and snippets.

View vishu-3's full-sized avatar
💭
I may be slow to respond.

ViShU vishu-3

💭
I may be slow to respond.
  • Nagpur,India
View GitHub Profile
@vishu-3
vishu-3 / README.md
Created March 23, 2023 12:46 — forked from jhoff/README.md
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]}"`)
@bhuvidya
bhuvidya / laravel-artisan-autocomplete.md
Last active September 11, 2023 09:42
Laravel artisan command auto-complete for BASH.

The inspiration for this comes from https://gist.github.com/jhoff/8fbe4116d74931751ecc9e8203dfb7c4

The following code gives you auto-complete for artisan commands in a BASH shell. Just add to your ~/.bash_profile. If you want a faster auto-complete, run art_cache from your project root to get a cached file of commands. To remove this file just run art_cache clear. If you haven't created a cache file, the script uses artisan list to get the command list dynamically (but this is a lot slower).

export ARTISAN_CMDS_FILE=bootstrap/cache/artisan-cmds.txt

function _artisan() {
    COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
@jhoff
jhoff / README.md
Last active April 1, 2024 07:45
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]}"`)