kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

How do I exclude files in the users directory from the tab completion? #462

Closed aidan-gallagher closed 7 months ago

aidan-gallagher commented 7 months ago

For my tool there is no reason a user should pass a local file to the script. Therefore I don't want the files to appear in the tab completion.

Here is an example of the output I see. On the last command (tab completed) I don't want files to appear just the argparse arguments.

aidan@ag474u:~/Code/Per/dpkg-buildenv$ ls
built_packages  debian  developer-packages.txt  dpkg-buildenv  Jenkinsfile  README.md  tmp  workspaces

aidan@ag474u:~/Code/Per/dpkg-buildenv$ dpkg-buildenv/dpkg_buildenv.py --help
usage: dpkg_buildenv.py [-h] [-nc] [-s SOURCES] [-it] [-d] [command]

positional arguments:
  command               Command to execute in the container. [Docker run argument]

optional arguments:
  -h, --help            show this help message and exit
  -nc, --no-cache       Do not use cache when building the image. [Docker build argument]
  -s SOURCES, --sources SOURCES
                        Select a sources file stored at /etc/dpkg-buildenv/sources.list.d/<SOURCE>.list.
  -it, --interactive-tty
                        Open an interactive terminal to the container. [Docker run argument]
  -d, --delete-images   Delete all build environment images generated by this tool

aidan@ag474u:~/Code/Per/dpkg-buildenv$ dpkg-buildenv/dpkg_buildenv.py  (<----This is where I hit tab)
built_packages/         --delete-images         .git/                   --help                  Jenkinsfile             .pytest_cache/          --sources
-d                      developer-packages.txt  .gitignore              --interactive-tty       -nc                     README.md               tmp/
debian/                 dpkg-buildenv/          -h                      -it                     --no-cache              -s                      workspaces/
aidan@ag474u:~/Code/Per/dpkg-buildenv$ dpkg-buildenv/dpkg_buildenv.py 
evanunderscore commented 7 months ago

Are you using zsh? This may be a duplicate of #458.

evanunderscore commented 7 months ago

Fixed in #463.