From 959ce18a2f5475988c8f4c02eeb3e191e1843150 Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Tue, 7 Oct 2025 13:19:12 +0300 Subject: [PATCH 1/3] Add Laravel artisan completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements tab completion for Laravel's artisan command-line tool. **Features:** - Dynamic command completion from `php artisan list` - Works with both `artisan` and `art` aliases - Only activates when artisan file exists in current directory - Uses `command` prefix to bypass user aliases for robustness - Follows bash-it completion conventions **Implementation:** - Parses `php artisan --raw --no-ansi list` output - Provides completions via bash's `compgen` builtin - Gracefully handles missing artisan file or PHP errors - Passes shellcheck and shfmt linting **Use Case:** Developers working with Laravel projects can now tab-complete artisan commands like `make:controller`, `migrate`, `tinker`, etc., improving productivity and reducing typos. Closes #2248 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- completion/available/artisan.completion.bash | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 completion/available/artisan.completion.bash diff --git a/completion/available/artisan.completion.bash b/completion/available/artisan.completion.bash new file mode 100644 index 0000000000..bf89e4081c --- /dev/null +++ b/completion/available/artisan.completion.bash @@ -0,0 +1,27 @@ +# shellcheck shell=bash +cite "about-completion" +about-completion "Laravel artisan completion" + +# Completion function for Laravel artisan +_artisan_completion() { + local cur commands + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + + # Only provide completions if artisan file exists in current directory or parent directories + if [[ ! -f "artisan" ]]; then + return 0 + fi + + # Get list of available artisan commands + # Use command prefix to bypass user aliases + commands=$(command php artisan --raw --no-ansi list 2> /dev/null | command sed "s/[[:space:]].*//g") + + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "${commands}" -- "${cur}")) + return 0 +} + +# Complete for both 'artisan' and common aliases 'art' +complete -F _artisan_completion artisan +complete -F _artisan_completion art From c7b03706dc6c215d02981c789514cce35c7d66a2 Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Tue, 7 Oct 2025 16:05:56 +0300 Subject: [PATCH 2/3] Apply review feedback: fix comment, remove /g, combine complete Applied 3 of 4 review suggestions from @akinomyoga: 1. Fixed comment - only checks current directory, not parent directories 2. Removed unnecessary /g flag from sed substitution 3. Combined two complete commands into one line Note on compgen -W quoting: Kept double quotes as single quotes would prevent variable expansion. The SC2034 warning is a false positive since commands is used in compgen. Artisan commands are safe (no special chars). Co-Authored-By: akinomyoga --- completion/available/artisan.completion.bash | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/completion/available/artisan.completion.bash b/completion/available/artisan.completion.bash index bf89e4081c..15cab5cda3 100644 --- a/completion/available/artisan.completion.bash +++ b/completion/available/artisan.completion.bash @@ -8,20 +8,19 @@ _artisan_completion() { COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" - # Only provide completions if artisan file exists in current directory or parent directories + # Only provide completions if artisan file exists in current directory if [[ ! -f "artisan" ]]; then return 0 fi # Get list of available artisan commands # Use command prefix to bypass user aliases - commands=$(command php artisan --raw --no-ansi list 2> /dev/null | command sed "s/[[:space:]].*//g") + commands=$(command php artisan --raw --no-ansi list 2> /dev/null | command sed "s/[[:space:]].*//") - # shellcheck disable=SC2207 + # shellcheck disable=SC2034,SC2207 COMPREPLY=($(compgen -W "${commands}" -- "${cur}")) return 0 } -# Complete for both 'artisan' and common aliases 'art' -complete -F _artisan_completion artisan -complete -F _artisan_completion art +# Complete for both 'artisan' and common alias 'art' +complete -F _artisan_completion artisan art From 03b49cfc954a6898ca76fd9b075509769153828d Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Tue, 7 Oct 2025 18:38:47 +0300 Subject: [PATCH 3/3] Update completion/available/artisan.completion.bash Co-authored-by: Koichi Murase --- completion/available/artisan.completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion/available/artisan.completion.bash b/completion/available/artisan.completion.bash index 15cab5cda3..9981e877e3 100644 --- a/completion/available/artisan.completion.bash +++ b/completion/available/artisan.completion.bash @@ -18,7 +18,7 @@ _artisan_completion() { commands=$(command php artisan --raw --no-ansi list 2> /dev/null | command sed "s/[[:space:]].*//") # shellcheck disable=SC2034,SC2207 - COMPREPLY=($(compgen -W "${commands}" -- "${cur}")) + COMPREPLY=($(compgen -W '${commands}' -- "${cur}")) return 0 }