diff --git a/kitty/complete.py b/kitty/complete.py index 67fe93d35..6a9b90835 100644 --- a/kitty/complete.py +++ b/kitty/complete.py @@ -108,6 +108,10 @@ def zsh_output_serializer(ans): cmd += ['-S', '""'] if description in ans.files_groups: cmd.append('-f') + common_prefix = os.path.commonprefix(tuple(matches)) + if common_prefix: + cmd.extend(('-p', shlex.quote(common_prefix))) + matches = {k[len(common_prefix):]: v for k, v in matches.items()} cmd.append('--') for word, description in matches.items(): cmd.append(shlex.quote(word))