I'm new on bash and I'm trying to write a bash script that will save user's input (some tags), to help this user I would like to allow completion based on my personal list of predefined tags only and not on the common TAB files completion (files names in the folder).
predefinedtags=(one two three four five)
echo "enter tags (separate multiple values by space)"
read -e tags
echo $tags
I would like that during the read
input the user can press TAB
to complete is word with the list of predefined tags. I thought it was an common question and method but I do not find a good way to do it. I found some posts that are a bit too complex for me and they seem to explain that is a not a so simple question. I don't even know if it's possible or not.
Changing tab-completion for read builtin in bash
bash and readline: tab completion in a user input loop?
Do you have any ideas ? Or there is maybe a completely different way to do it ? Thank you for your help.