1

I would like to create a bash script foo.sh.

When it runs, it will prompt for a directory. The user will be able to use tab to auto complete?

Here is some example code assuming read has some option.

echo -n "Enter the directory of awesomeness: "
read --enable-autocomplete DIR_OF_AWESOMENESS
echo "The Dir of Awesomeness is $DIR_OF_AWESOMENESS"

Thanks!

3

Bash auto-completion works on command-line arguments. Here is a two-part introduction for writing auto-completion with examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.