如何设置 bash 自动补全

当使用 bash 作为 shell 时,pytest 可以使用 argcomplete (https://kislyuk.github.io/argcomplete/) 自动补全。为此 argcomplete 需要安装并启用。

安装 argcomplete:

sudo pip install 'argcomplete>=0.5.7'

要全局激活所有启用 argcomplete 的 python 应用程序,请运行:

sudo activate-global-python-argcomplete

对于永久的(但不是全局的) pytest 激活,使用:

register-python-argcomplete pytest >> ~/.bashrc

对于一次性激活 argcomplete 只为 pytest,使用:

eval "$(register-python-argcomplete pytest)"