I was just wondering if it is possible to write a Python script that is run in the shell that can provide suggestions to the user when they hit Tab?
for example, how certain applications can limit the file types suggested by what they support. I haven't found anything in optParse that does this?
Ideally it would be:
myScript.py [TAB] (shell prints list of options)
Any suggestions? Specifically using KDE under OpenSuse and tcsh
Much appreciated
That is a feature of the shell, not of the Python script being called. See this question on SO for more info on shell completion. In particular, you're looking for programmable completion.
I think you're looking for something like optcomplete. It implements a completion module for bash that will autocomplete the options for any Python program that uses optparse
. You could take hints from that and convert it to what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With