kislyuk / argcomplete

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

auto completion with tab key not working #400

Closed puneet336 closed 1 year ago

puneet336 commented 1 year ago

Hi , I am using a Rockylinux 9 and i am trying to setup a basic auto complete script as normal user on this system.

[puneet@master1 ~]$ python3 --version
Python 3.9.14
[puneet@master1 ~]$ cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.1 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.1"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.1 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.1"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.1"
[puneet@master1 ~]$

Here are the steps i performed so far -

mkdir -p $HOME/bash_completion.d
activate-global-python-argcomplete --dest=$HOME/bash_completion.d

Here's what i appended in the default .bashrc (tail -n5 ~/.bashrc) :

echo Hi
export PATH=$PATH:/home/puneet/myproj/amp/bin/
eval "$(/home/puneet/bash_completion.d/python-argcomplete /home/puneet/myproj/amp/bin/amp)"

and this is a demo wrapper script for which i am trying to get the auto completion working -

[puneet@master1 ~]$ cat /home/puneet/myproj/amp/bin/amp
#!/usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK
import argparse
import argcomplete

main_parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
main_parser.add_argument('--nolog',  action='store_true',required=False,  dest='nolog', help=" do not perform logging")

argcomplete.autocomplete(main_parser)
args = main_parser.parse_args()

and here's what i see when i type tab after typing in amp -

[puneet@master1 ~]$ bash
HI
[puneet@master1 ~]$ amp
bash_completion.d/        Desktop/                  Music/                    Templates/
.bash_history             Documents/                myproj/                   Videos/
.bash_logout              Downloads/                Pictures/                 .viminfo

and i was expecting "--nolog"

Did i miss any step here ? Please advice.

puneet336 commented 1 year ago

found the issue -

~eval "$(/home/puneet/bash_completion.d/python-argcomplete /home/puneet/myproj/amp/bin/amp)"~ eval "$(register-python-argcomplete amp)"