File tree Expand file tree Collapse file tree 2 files changed +79
-0
lines changed
Expand file tree Collapse file tree 2 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ PHP Code compiler - Phar executable compiling utility
1717- [ Install] ( #install )
1818 - [ Requirements] ( #requirements )
1919 - [ Quick install] ( #quick-install )
20+ - [ Bash completion] ( #bash-completion )
2021 - [ Github Action] ( #github-action )
2122- [ License] ( #license )
2223
@@ -137,6 +138,18 @@ _Add execution permissions to the binary_
137138chmod +x ${BINDIR} /phpcc
138139```
139140
141+ ### Bash completion
142+
143+ A [ bash completion script] ( /etc/bash_completion.d/phpcc-completion ) is also available.
144+
145+ ``` bash
146+ # Download the bash completion script
147+ curl -Lo ${BINDIR} /phpcc https://github.com/yannoff/phpcc/releases/latest/download/phpcc-completion
148+
149+ # Add the script to bash completion directory
150+ sudo mv phpcc-completion /etc/bash_completion.d/phpcc-completion
151+ ```
152+
140153### Github Action
141154
142155A [ github action] ( actions/install/action.yaml ) is available for integration in CI scripts.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ #
4+ # This file is part of the PHP Code Compiler project
5+ #
6+ # Copyright (c) Yannoff (https://github.com/yannoff)
7+ #
8+ # @project PHP Code Compiler (yannoff/phpcc)
9+ # @homepage https://github.com/yannoff/phpcc
10+ # @license https://github.com/yannoff/phpcc/blob/main/LICENSE
11+ #
12+ # For the full copyright and license information, please view
13+ # the LICENSE file that was distributed with this source code.
14+ #
15+
16+ #
17+ # Remove - or -- prefix from an option name beginning
18+ #
19+ # args:
20+ # $1: the raw option name (eg: "-op" or "--long-o")
21+ #
22+ __trim (){ local w=$1 ; if [ " ${w: 0: 2} " = " --" ]; then echo ${w: 2} ; elif [ " ${w: 0: 1} " = " -" ]; then echo ${w: 1} ; else echo ${w} ; fi }
23+
24+ #
25+ # PHP Code Compiler bash completion command
26+ #
27+ # args:
28+ # $1: the command word
29+ # $2: the current word
30+ # $3: the previous word
31+ #
32+ __comp_phpcc_command (){
33+ local prev=$3 cur=$2 options=()
34+
35+ options+=( banner )
36+ options+=( debug )
37+ options+=( dir )
38+ options+=( file )
39+ options+=( help )
40+ options+=( main )
41+ options+=( meta )
42+ options+=( no-minify )
43+ options+=( output )
44+ options+=( quiet )
45+ options+=( shebang-less )
46+
47+ case " ${prev} " in
48+ --banner|--dir|--file|--main|--output)
49+ # if previous typed option expects a file or directory path,
50+ # let the reply empty so that readline's default
51+ # completion is attempted
52+ ;;
53+
54+ * )
55+ case " $cur " in
56+ -* |" " )
57+ compgen -W " ${options[*]} " -P -- $( __trim ${cur} )
58+ ;;
59+
60+ * )
61+ ;;
62+ esac
63+ ;;
64+ esac
65+ }
66+ complete -o default -C __comp_phpcc_command phpcc
You can’t perform that action at this time.
0 commit comments