-
Notifications
You must be signed in to change notification settings - Fork 2
/
completion.sh
54 lines (46 loc) · 1.74 KB
/
completion.sh
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
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function _getTermToolsOptions () {
local word=${COMP_WORDS[COMP_CWORD]}
local prevWord=${COMP_WORDS[COMP_CWORD - 1]}
local line=${COMP_LINE}
case "$prevWord" in
"set")
COMPREPLY=( $(compgen -W "theme" -- $word) )
;;
"theme")
scriptsList=`ls $DIR/themes | sed 's/\(.*\)\..*/\1 /' | tr -d '\n' 2>/dev/null`
COMPREPLY=( $(compgen -W "$scriptsList" -- $word) )
;;
*)
COMPREPLY=( $(compgen -W 'restore remove reload check apply set help version version customize' -- $word ) )
esac
}
complete -F _getTermToolsOptions termtools
function _getNPMOptions () {
local word=${COMP_WORDS[COMP_CWORD]}
local prevWord=${COMP_WORDS[COMP_CWORD - 1]}
local line=${COMP_LINE}
case "$prevWord" in
"run")
scriptsList=`node -e "\
console.log(\
Object.keys(\
require('./package.json').scripts\
).filter(item => {\
if(item.startsWith('pre') || item.startsWith('post')) {\
return false\
} else {\
return true\
}\
}).join(' ')\
)" 2>/dev/null`
COMPREPLY=( $(compgen -W "$scriptsList" -- $word) )
;;
"version")
COMPREPLY=( $(compgen -W "patch minor major" -- $word) )
;;
*)
COMPREPLY=( $(compgen -W 'run start test access adduser bin bugs cache completion config ddp dedupe deprecate dist-tag docs doctor edit explore get help help-search init install link list login logout ls outdated owner pack ping prefix profile prune publish uninstall unpublish unstar update version view whoami' -- $word ) )
esac
}
complete -F _getNPMOptions npm