当调用"read"时,获得自动补全功能.在Bash脚本中 [英] Get autocompletion when invoking a "read" inside a Bash script
本文介绍了当调用"read"时,获得自动补全功能.在Bash脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Bash脚本中,我正在读取用户使用read
输入的一些变量:
Inside my Bash script, I'm reading some variables entered by the user with read
:
read -p "Glassfish Path:" GF_DIR
现在,我希望用户在必须输入目录时(例如当您在Bash shell上时)获得自动补全功能.因此,当他输入目录的前几个字母时,可以通过单击TAB来自动完成该目录. 有可能吗?
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?
推荐答案
尝试:
read -e -p "Glassfish Path:" GF_DIR
-e
启用阅读行:
-e
If the standard input is coming from a terminal, Readline is used
to obtain the line.
这篇关于当调用"read"时,获得自动补全功能.在Bash脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文