python - TAB 自动完成 python CLI

标签 python shell kde-plasma tcsh

我只是想知道是否可以编写一个在 shell 中运行的 Python 脚本,以便在用户点击 Tab 时向他们提供建议?

例如,某些应用程序如何限制它们所支持的建议的文件类型。 我在 optParse 中没有找到任何可以做到这一点的东西吗?

理想情况下:

myScript.py [TAB] (shell prints list of options)

有什么建议吗?具体使用OpenSuse下的KDE和tcsh

非常感谢

最佳答案

这是 shell 的特性,而不是被调用的 Python 脚本的特性。参见 this question on SO有关 shell 完成的更多信息。特别是,您正在寻找 programmable completion .

关于python - TAB 自动完成 python CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13576488/

相关文章:

bash - 自定义 cd 命令

shell - `set` shell 中的选项

Slackware 13.37 KDE 错误上的 mysql-workbench

linux - kde 'window shortcuts' 是临时的

linux - 适用于 Linux 的最小 Xwindow

python - Pdal 安装过程中出错

python - 如何让GtkMenuToolButton在发出 'clicked'信号时打开相同的菜单?

python - 使用 xarray 中的名称索引设置值

linux - 从 bash 中的 Json 中提取值

python - 使用python的join函数格式化字典