blob: b3c1941974e132573e25f3f1e7532c1d2feb44b1 (
plain)
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
|
#/usr/bin/env bash
_kresctl_completion()
{
COMPREPLY=()
local cur prev opts
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# check if there is a word is empty
# that means there is a space after last non-empty word
if [[ -z "$cur" ]]
then
# no word to complete, return all posible options
opts=$(kresctl completion --bash --space "${COMP_WORDS}")
else
opts=$(kresctl completion --bash "${COMP_WORDS}")
fi
# if there is no completion from kresctl
# auto-complete just directories and files
if [[ -z "$opts" ]]
then
COMPREPLY=($(compgen -d -f "${cur}"))
else
COMPREPLY=( $(compgen -W "${opts}" ${cur}) )
fi
return 0
}
complete -o filenames -o dirnames -F _kresctl_completion kresctl
|