Completion for fish

This commit is contained in:
Pablo S. Blum de Aguiar 2018-08-27 00:51:30 +02:00
parent 1949f3c3d5
commit 1b7244f3c8
2 changed files with 33 additions and 0 deletions

View File

@ -371,6 +371,16 @@ Add the following to your :file:`~/.bashrc`
source <(kitty + complete setup bash)
fish
~~~~~~~~
Add the following to your :file:`~/.config/fish/config.fish`
.. code-block:: sh
kitty + complete setup fish | source
zsh
~~~~~~~~~

View File

@ -56,6 +56,14 @@ kitty_completions() {
}
complete -o nospace -F kitty_completions kitty
''',
'fish': '''
function __kitty_completions
# Send all words up to the one before the cursor
commandline -cop | kitty +complete fish
end
complete -f -c kitty -a "(__kitty_completions)"
''',
}
@ -86,6 +94,11 @@ def bash_input_parser(data):
return words, new_word
@input_parser
def fish_input_parser(data):
return data.rstrip().splitlines(), True
@output_serializer
def zsh_output_serializer(ans):
lines = []
@ -117,6 +130,16 @@ def bash_output_serializer(ans):
# }}}
@output_serializer
def fish_output_serializer(ans):
lines = []
for matches in ans.match_groups.values():
for word in matches:
lines.append(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'] = {