blob: 3ef614ec9b8ef1f2a17257854b5be4f8f428ea30 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# -*- mode: sh; indent-tabs-mode: nil; -*- vim: set ft=sh tw=80 sw=4 et :
# Copyright 2005-2023 Gentoo Authors
# Distributed under the terms of the GNU GPL version 2 or later
# bash command-line completion for eselect
# Author: Aaron Walker <ka0ttic@gentoo.org>
# Maintainer: <eselect@gentoo.org>
_eselect() {
local cur sedcmd2 sedcmd3 possibles
local options="--brief --color= --colour= --eprefix= --root="
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
sedcmd2='s/^ \([[:alnum:]-][[:alnum:]_-]*\)[[:space:],].*$/\1/p'
sedcmd3='s/^ \[[[:digit:]][[:digit:]]*\] *\([[:graph:]]*\).*$/\1/p'
set -- "${COMP_WORDS[@]:1}"
# skip global options
while [[ $# -gt 1 && $1 == -* ]]; do
[[ $2 == "=" ]] && shift 2
shift
done
# skip any subaction options
while [[ $# -gt 3 && $3 == -* ]]; do
set -- "${@:1:2}" "${@:4}"
done
case $# in
0|1) possibles="${options} $(eselect modules list --only-names \
2>/dev/null)" ;;
2) possibles=$(eselect --brief "$1" usage 2>/dev/null \
| sed -n -e "${sedcmd2}") ;;
3)
case $2 in
set|enable|disable)
possibles=$(eselect "$1" list 2>/dev/null \
| sed -n -e "${sedcmd3}") ;;
esac
;;
esac
if [[ -n "${possibles}" ]]; then
COMPREPLY=( $(compgen -W "${possibles}" -- ${cur}) )
[[ ${COMPREPLY[0]} == *= ]] && compopt -o nospace
fi
return 0
}
complete -F _eselect eselect
|