Inside my Bash script, I'm reading some variables entered by the user with read
:
read -p "Glassfish Path:" GF_DIR
Now I want that the user gets a autocompletion when he has to enter a directory, like when you are on the Bash shell. So when he enters the first letters of a directory, he can autocomplete it by hitting TAB. Is that possible?
bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.
The programmable completion feature in Bash permits typing a partial command, then pressing the [Tab] key to auto-complete the command sequence. [1] If multiple completions are possible, then [Tab] lists them all. Let's see how it works. Tab completion also works for variables and path names.
Try:
read -e -p "Glassfish Path:" GF_DIR
-e
enables readline:
-e If the standard input is coming from a terminal, Readline is used to obtain the line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With