Skip to content

Commit bd58e04

Browse files
committed
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
1 parent 66de0da commit bd58e04

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

etc/bash_completion.d/phpcc-completion

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,18 @@ __comp_phpcc_command(){
4545
options+=( shebang-less )
4646

4747
case "${prev}" in
48-
--banner|--dir|--file|--main|--output)
49-
# if a previous typed option expects a file or directory path,
50-
# let the reply empty so that readline's default completion is used
48+
# previous typed option expects a file path
49+
--banner|--file|--main|--output)
50+
compgen -d -f ${cur}
51+
;;
52+
53+
# previous typed option expects a directory path
54+
--dir)
55+
compgen -d ${cur}
56+
;;
57+
58+
# previous typed option is not elligible to completion
59+
--meta)
5160
;;
5261

5362
*)
@@ -61,4 +70,4 @@ __comp_phpcc_command(){
6170
;;
6271
esac
6372
}
64-
complete -o default -C __comp_phpcc_command phpcc
73+
complete -C __comp_phpcc_command phpcc

0 commit comments

Comments
 (0)