I'm writing a little CLI in Python (as an extension to Mercurial) and would like to support tab-completion. Specifically, I would like catch tabs in the prompt and show a list of matching options (just like bash).
Example: Enter section name:
ext*TAB*
extensions
extras
The problem is I'm not sure how to catch the Tab events. I'm using the ui.prompt()
API of Mercurial, which is just calling raw_input()
under the hood.
As far as I know, raw_input()
only returns on 'enter' and if a user enters a tab, the string returned simply includes a "\t"
.