From bbefcb2cd279b3a99a0eeee5015d38d5ba5d463a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 26 Aug 2018 18:22:40 +0530 Subject: [PATCH] Fix spaces after file/dir names and config directive names in bash completion Since bash has no concept of completion groups with customizable behavior, unlike zsh, we tell it to never add trailing spaces and add the spaces ourselves. --- kitty/complete.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kitty/complete.py b/kitty/complete.py index f735a9765..472c1c15f 100644 --- a/kitty/complete.py +++ b/kitty/complete.py @@ -55,7 +55,7 @@ kitty_completions() { fi } -complete -F kitty_completions kitty +complete -o nospace -F kitty_completions kitty ''', } @@ -106,8 +106,11 @@ def zsh_output_serializer(ans): @output_serializer def bash_output_serializer(ans): lines = [] - for matches in ans.match_groups.values(): + for description, matches in ans.match_groups.items(): + needs_space = description not in ans.no_space_groups for word in matches: + if needs_space: + word += ' ' lines.append('COMPREPLY+=({})'.format(shlex.quote(word))) # debug('\n'.join(lines)) return '\n'.join(lines)