mirror of
https://github.com/endeavouros-team/welcome.git
synced 2026-06-13 01:24:34 +00:00
56 lines
1.4 KiB
Bash
56 lines
1.4 KiB
Bash
# 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
|