mirror of
https://github.com/kmod-project/kmod.git
synced 2026-01-27 01:44:26 +00:00
Note that completions are explicitly aimed to be simple, depending on as little as possible shell specific helpers. The goal is that people unfamiliar with these can extend them with zero ramp-up. Doing things efficiently or "properly" is somewhat secondary. v2: - wire the completions to the autotools build v3: - use SPDX style copyright statements Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/138 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
31 lines
845 B
Bash
31 lines
845 B
Bash
# lsmod(8) completion -*- shell-script -*-
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
#
|
|
# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
|
|
#
|
|
# Formatted using:
|
|
# shfmt --language-dialect bash --indent 4 --func-next-line
|
|
|
|
_lsmod()
|
|
{
|
|
# long/short opt pairs
|
|
local -A opts=(
|
|
['syslog']='s'
|
|
['verbose']='v'
|
|
['version']='V'
|
|
['help']='h'
|
|
)
|
|
|
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
if [[ $cur == --* ]]; then
|
|
COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
|
|
elif [[ $cur == -* ]]; then
|
|
if (( ${#cur} != 2 )); then
|
|
COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
|
|
fi
|
|
COMPREPLY+=($(compgen -P '-' -W "${opts[*]}" -- "${cur:1}"))
|
|
fi
|
|
} &&
|
|
complete -F _lsmod lsmod
|