Complete as-you-type on command line with python

2019-05-07 00:02发布

I would like to write a small application/directory/file launcher in python. To make it fast i would like to autocomplete/autosuggest entries. But i want to display these suggestions as the user types. From what i have read about the readline module completion is only possible using a "Completion hotkey" e.g. Tab.

Any suggestions ?

Using curses with filter as suggested below does not seem to work. This minimal example clears my screen despite the call to filter():

import curses

curses.filter()
win = curses.initscr()

curses.noecho()
curses.cbreak()


while 1:
  key = win.getkey()
  win.echochar(key)
  if key == "Q":
    break

curses.endwin()

1条回答
ら.Afraid
2楼-- · 2019-05-07 00:33
登录 后发表回答