Completion for bash

This commit is contained in:
Kovid Goyal
2018-08-26 09:16:02 +05:30
parent 933cced76c
commit f36a9fffa3
2 changed files with 31 additions and 0 deletions

View File

@@ -44,6 +44,13 @@ def zsh_input_parser(data):
return words, new_word
@input_parser
def bash_input_parser(data):
new_word = data.endswith('\n\n')
words = data.rstrip().splitlines()
return words, new_word
@output_serializer
def zsh_output_serializer(ans):
lines = []
@@ -59,6 +66,16 @@ def zsh_output_serializer(ans):
return '\n'.join(lines)
@output_serializer
def bash_output_serializer(ans):
lines = []
for matches in ans.match_groups.values():
for word in matches:
lines.append('COMPREPLY+=({})'.format(shlex.quote(word)))
# debug('\n'.join(lines))
return '\n'.join(lines)
def completions_for_first_word(ans, prefix, entry_points, namespaced_entry_points):
cmds = ['@' + c for c in cmap]
ans.match_groups['Entry points'] = {