mirror of
https://github.com/endeavouros-team/eos-pkgbuild-setup.git
synced 2026-09-26 17:51:43 +00:00
63 lines
1.6 KiB
Bash
63 lines
1.6 KiB
Bash
# bash completion for assets.make -*- shell-script -*-
|
|
|
|
_assets_make_listselector()
|
|
{
|
|
local cur="$1"
|
|
local list_elems_all="$2"
|
|
|
|
local realcur="${cur##*,}"
|
|
local prefix="${cur%$realcur}"
|
|
local elems word
|
|
|
|
for word in $list_elems_all
|
|
do
|
|
if ! [[ $prefix == *"$word"* ]]; then
|
|
elems="$word $elems"
|
|
fi
|
|
done
|
|
COMPREPLY=( $(compgen -P "$prefix" -W "$elems" -S ',' -- $realcur) )
|
|
compopt -o nospace
|
|
}
|
|
|
|
_assets_make_complete_simple() {
|
|
COMPREPLY=($(compgen -W "$1" -- "$cur"))
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
}
|
|
|
|
_assets_make_complete_open() {
|
|
COMPREPLY=($(compgen "$@"))
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
}
|
|
|
|
_assets_make_() {
|
|
local cur prev #words cword split
|
|
_init_completion -s || return
|
|
|
|
local -r opts="$(assets.make --dump-options)"
|
|
|
|
# Handle options that need sub-options.
|
|
# Each option "case" should return immediately.
|
|
|
|
case "$prev" in
|
|
--fetch-timeout)
|
|
_assets_make_complete_open -P "$cur" -W "{0..9}"
|
|
;;
|
|
--pkgnames)
|
|
_assets_make_listselector "$cur" "$(pacman -Slq endeavouros)"
|
|
;;
|
|
*)
|
|
# Handle all top-level parameters.
|
|
case "$cur" in
|
|
-* | "")
|
|
# Any option or nothing yet.
|
|
_assets_make_complete_simple "$opts"
|
|
;;
|
|
*)
|
|
# Non-option parameters.
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
} &&
|
|
complete -F _assets_make_ assets.make
|