Add some docs for how the completion system can be extended for a new shell
This commit is contained in:
parent
3fb00f6c70
commit
c84e73d8e6
@ -12,6 +12,25 @@ from .cli import options_for_completion, parse_option_spec
|
|||||||
from .cmds import cmap
|
from .cmds import cmap
|
||||||
from .shell import options_for_cmd
|
from .shell import options_for_cmd
|
||||||
|
|
||||||
|
'''
|
||||||
|
To add completion for a new shell, you need to:
|
||||||
|
|
||||||
|
1) Add an entry to completion scripts for your shell, this is
|
||||||
|
a simple function that call's kitty's completion code and passes the
|
||||||
|
results to the shell's completion system. This can be output by
|
||||||
|
`kitty +complete setup shell_name` and its output goes into
|
||||||
|
your shell's rc file.
|
||||||
|
|
||||||
|
2) Add an input_parser function, this takes the input from
|
||||||
|
the shell for the text being completed and returns a list of words
|
||||||
|
alongwith a boolean indicating if we are on a new word or not. This
|
||||||
|
is passed to kitty's completion system.
|
||||||
|
|
||||||
|
3) An output_serializer function that is responsible for
|
||||||
|
taking the results from kitty's completion system and converting
|
||||||
|
them into something your shell will understand.
|
||||||
|
'''
|
||||||
|
|
||||||
parsers, serializers = {}, {}
|
parsers, serializers = {}, {}
|
||||||
|
|
||||||
|
|
||||||
@ -131,7 +150,6 @@ def bash_output_serializer(ans):
|
|||||||
lines.append('COMPREPLY+=({})'.format(shlex.quote(word)))
|
lines.append('COMPREPLY+=({})'.format(shlex.quote(word)))
|
||||||
# debug('\n'.join(lines))
|
# debug('\n'.join(lines))
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
# }}}
|
|
||||||
|
|
||||||
|
|
||||||
@output_serializer
|
@output_serializer
|
||||||
@ -142,6 +160,7 @@ def fish_output_serializer(ans):
|
|||||||
lines.append(shlex.quote(word))
|
lines.append(shlex.quote(word))
|
||||||
# debug('\n'.join(lines))
|
# debug('\n'.join(lines))
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def completions_for_first_word(ans, prefix, entry_points, namespaced_entry_points):
|
def completions_for_first_word(ans, prefix, entry_points, namespaced_entry_points):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user