From 84794c00c0affa2b8bfce0b6bf7b425eccb0012b Mon Sep 17 00:00:00 2001 From: Yannoff Date: Sun, 16 Nov 2025 23:34:27 +0100 Subject: [PATCH] Fix: Imrpove bash completion command logic Fine-tune completion command logic: - Remove `default` option switch in completion specification - Complete `--file` option with directory/file paths compgen - Complete other path related options with directory names only - Don't attempt completion after the `--meta` option comp word --- etc/bash_completion.d/phpcc-completion | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/etc/bash_completion.d/phpcc-completion b/etc/bash_completion.d/phpcc-completion index ced7c82..905fc9f 100644 --- a/etc/bash_completion.d/phpcc-completion +++ b/etc/bash_completion.d/phpcc-completion @@ -45,9 +45,18 @@ __comp_phpcc_command(){ options+=( shebang-less ) case "${prev}" in - --banner|--dir|--file|--main|--output) - # if a previous typed option expects a file or directory path, - # let the reply empty so that readline's default completion is used + # previous typed option expects a file path + --banner|--file|--main|--output) + compgen -d -f ${cur} + ;; + + # previous typed option expects a directory path + --dir) + compgen -d ${cur} + ;; + + # previous typed option is not elligible to completion + --meta) ;; *) @@ -61,4 +70,4 @@ __comp_phpcc_command(){ ;; esac } -complete -o default -C __comp_phpcc_command phpcc +complete -C __comp_phpcc_command phpcc