4 class RainbowCompleter(object):
6 def __init__(self
, options
):
10 self
.options
= sorted(options
)
13 def complete(self
, text
, state
):
22 if s
and s
.startswith(text
)]
24 self
.matches
= self
.options
[:]
27 response
= self
.matches
[state
]
33 def init_interactive_shell(set):
35 Init the rainbow shell
37 readline
.set_completer(RainbowCompleter(set).complete
)
38 readline
.parse_and_bind('set editing-mode vi')
39 readline
.parse_and_bind("set input-meta on")
40 readline
.parse_and_bind("set convert-meta off")
41 readline
.parse_and_bind("set output-meta on")
42 if 'libedit' in readline
.__doc
__:
43 readline
.parse_and_bind("bind ^I rl_complete")
45 readline
.parse_and_bind("tab: complete")