From 6d1fd2054216403fa4d11614bd5da3d48de395d4 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Tue, 10 Mar 2020 20:16:27 +0100 Subject: [PATCH] Add #compdef comment to zsh completion This will allow adding completions without using `kitty + complete setup zsh | source /dev/stdin` by piping the code into a file named `_kitty` in a directory in `$fpath` instead of piping to `source`. This is especially handy for package managers that package kitty. See https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org. The `compdef _kitty kitty` line at the end doesn't seem to have any ill effects when using the completion code in a completion function file. When piping the code to `source` like before, the added line should be interpreted as a comment and be ignored. --- kitty/complete.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kitty/complete.py b/kitty/complete.py index e6a5e64e4..c930c5249 100644 --- a/kitty/complete.py +++ b/kitty/complete.py @@ -61,7 +61,8 @@ def remote_control_command_names() -> Tuple[str, ...]: completion_scripts = { - 'zsh': ''' + 'zsh': '''#compdef kitty + _kitty() { local src # Send all words up to the word the cursor is currently on