shell - tab autocomplete on python script execution in console -


i'm having "issue" (for lack of better word), whenever run python script arguments, can't use tab completion function of unix consoles. example when want put file in script execution. hope examples illustrate better issue.

case 1

>python3 script.py  [tab]  folder/ folder1/ data.dat 

case 2

>python3 script.py -f d  [tab]  folder/ folder1/ (file data.dat not showing) 

ideal case

>python3 script.py -f data.dat - n 2 .... 

hope made myself clear, , can explain me, i'm guessing python won't allow this, or needs configured in someway.

i'm using argparse in script usual code..

    ap.add_argument('-f', '--file', type=str, action='store', help='input file.',metavar='file') 

i've tried type=argparse.filetype('r') same.

i want achieve because of files i'm working have long names, , requested not write files names every time.

anyway, reading.

ok, work around this. using python 3.5 can achieve wanted, autocomplete name of files in bash when executing python script.

so with

> python3 script.py [tab]  folder/ folder1/ data.dat > python3 script.py -f d [tab] folder/ folder1/ (file data.dat not showing) 

and python 3.5

> python3.5 script.py -f d [tab]  folder/ folder1/ data.dat 

this pages lead me valueable answers too.

https://docs.python.org/3/tutorial/interactive.html

https://argcomplete.readthedocs.io/en/latest/

thanks again.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -