如何设置 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

要一次性仅为 pytest 激活 argcomplete,使用:

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