-
Notifications
You must be signed in to change notification settings - Fork 1
/
welcome.bash-completion
55 lines (48 loc) · 1.42 KB
/
welcome.bash-completion
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
# bash completion for welcome -*- shell-script -*-
_welcome_complete_simple() {
COMPREPLY=($(compgen -W "$1" -- "$cur"))
[[ $COMPREPLY == *= ]] && compopt -o nospace
}
_welcome_complete_open() {
COMPREPLY=($(compgen "$@"))
[[ $COMPREPLY == *= ]] && compopt -o nospace
}
_welcome_() {
local cur prev #words cword split
_init_completion -s || return
local -r opts=(
--help -h
--enable -f
--disable
--once -1
--installer
--version
--lang=
--startdelay=
)
local -r langs1=(/usr/share/endeavouros/scripts/translation-*.bash) # rs ???
local -r langs=$(printf "%s\n" ${langs1[*]} | sed -E 's|/usr.*translation-([^\.]+)\.bash|\1|')
# Handle options that need sub-options.
# Each option "case" should return immediately.
case "$prev" in
--lang)
_welcome_complete_simple "$langs"
;;
--startdelay)
_welcome_complete_open -P "$cur" -W "{0..9}"
;;
*)
# Handle all top-level parameters.
case "$cur" in
-* | "")
# Any option or nothing yet.
_welcome_complete_simple "${opts[*]}"
;;
*)
# Non-option parameters.
;;
esac
;;
esac
} &&
complete -F _welcome_ welcome eos-welcome