shtab
shtab copied to clipboard
Completion of environment variable names
When working in shells it is common to store values in environment variables, and most commands allow tab completion of environment variable names, for example:
$ echo $BASH_V<TAB>
$ echo $BASH_VERSI<TAB><TAB>
$BASH_VERSINFO $BASH_VERSION
$ echo $BASH_VERSIO<TAB>
$ echo $BASH_VERSION
Unfortunately, when an shtab completion script is activated, the completion of environment variable names doesn't work. For instance take the following script:
from argparse import ArgumentParser
import shtab
parser = ArgumentParser()
parser.add_argument("--pid", type=int)
shtab.add_argument_to(parser, "--shell-completion")
print(parser.parse_args())
The following doesn't complete anything:
$ cli.py --pid $BASHP<TAB><TAB>