add bash completion

This commit is contained in:
Denis Lehmann 2024-07-17 22:38:14 +02:00
parent 2d9b0f77b3
commit cbf64a2e14
2 changed files with 17 additions and 0 deletions

16
gra_completion.bash Normal file
View file

@ -0,0 +1,16 @@
function _gra_completion {
_args="-h --help"
# Add config values to completion
if [ "${#COMP_WORDS[@]}" -lt 3 ] && [ -f ~/.config/gra.config ]; then
readarray -t lines < ~/.config/gra.config
for line in "${lines[@]}"; do
[[ "$line" =~ ^(.*)= ]] && _args="$_args ${BASH_REMATCH[1]}"
done
fi
COMPREPLY=($(compgen -W "$_args" -- "${COMP_WORDS[COMP_CWORD]}"))
}
complete -F _gra_completion gra