forked from phpbrew/phpbrew
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_phpbrew
More file actions
81 lines (74 loc) · 2.34 KB
/
Copy path_phpbrew
File metadata and controls
81 lines (74 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Author: @marcioAlmada
# TLDR: bash completion for phpbrew
# NOTICE: this script must be updated with any changes to, or additions to phpbrew commands.
_phpbrew_comp()
{
local cur prev prev_prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
prev_prev="${COMP_WORDS[COMP_CWORD-2]}"
opts="help init known install list use switch info env ext variants config download clean self-update remove purge"
case "${prev}" in
init|known|list|env|variants|config|self-update)
return 0
;;
esac
case "${prev}" in
use|switch|download|clean|remove|purge)
# list installed php versions (system wide not included)
opts="$(ls $PHPBREW_HOME/php/ | cut -d '-' -f 2)"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
case "${prev}" in
ext)
# list extension commands
opts="install enable disable"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
case "${prev}" in
install)
case "${prev_prev}" in
ext)
# list available extensions
opts="$(cd $PHPBREW_HOME/build/$PHPBREW_PHP/ext/ && ls -d */ | cut -d '/' -f 1)"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
;;
enable)
case "${prev_prev}" in
ext)
# list available extensions
opts="$(cd $PHPBREW_HOME/php/$PHPBREW_PHP/var/db/ && ls | grep .disabled | cut -d '.' -f 1)"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
;;
disable)
case "${prev_prev}" in
ext)
# list available extensions
opts="$(cd $PHPBREW_HOME/php/$PHPBREW_PHP/var/db/ && ls | grep --invert-match .disabled | cut -d '.' -f 1)"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
;;
esac
case "${cur}" in
*)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
return 0
} &&
complete -F _phpbrew_comp phpbrew