Now completion for hyperlinked_grep is automatic thanks to delegation
Also fix delegation for zsh when the command being completed differs from the current command.
This commit is contained in:
parent
5666b1b0fd
commit
54ec486d3a
@ -43,34 +43,6 @@ You can now run searches with::
|
|||||||
|
|
||||||
hg some-search-term
|
hg some-search-term
|
||||||
|
|
||||||
If you want to enable completion, for the kitten, you can delegate completion
|
|
||||||
to :program:`rg`. How to do that varies based on the shell:
|
|
||||||
|
|
||||||
|
|
||||||
.. tab:: zsh
|
|
||||||
|
|
||||||
Instead of using an alias, create a simple wrapper script named
|
|
||||||
:program:`hg` somewhere in your :envvar:`PATH`:
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
#!/bin/sh
|
|
||||||
exec kitty +kitten hyperlinked_grep "$@"
|
|
||||||
|
|
||||||
Then, add the following to :file:`.zshrc`::
|
|
||||||
|
|
||||||
compdef _rg hg
|
|
||||||
|
|
||||||
.. tab:: fish
|
|
||||||
|
|
||||||
You can combine both the aliasing/wrapping and pointing fish to ripgrep's
|
|
||||||
autocompletion with a fish wrapper function in your :file:`config.fish`
|
|
||||||
or :file:`~/.config/fish/functions/hg.fish`:
|
|
||||||
|
|
||||||
.. code-block:: fish
|
|
||||||
|
|
||||||
function hg --wraps rg; kitty +kitten hyperlinked_grep $argv; end
|
|
||||||
|
|
||||||
To learn more about kitty's powerful framework for customizing URL click
|
To learn more about kitty's powerful framework for customizing URL click
|
||||||
actions, see :doc:`here </open_actions>`.
|
actions, see :doc:`here </open_actions>`.
|
||||||
|
|
||||||
|
|||||||
@ -166,6 +166,7 @@ def completion(self: TestCompletion, tdir: str):
|
|||||||
add('kitty -1 bash ', is_delegate(2, 'bash'))
|
add('kitty -1 bash ', is_delegate(2, 'bash'))
|
||||||
add('kitty -1 bash --n', is_delegate(2, 'bash'))
|
add('kitty -1 bash --n', is_delegate(2, 'bash'))
|
||||||
add('kitty @launch --type tab bash --n', is_delegate(4, 'bash'))
|
add('kitty @launch --type tab bash --n', is_delegate(4, 'bash'))
|
||||||
|
add('kitty +kitten hyperlinked_grep --s', is_delegate(2, 'rg'))
|
||||||
add('kitty @launch e', all_words('exe1', 'exe2'))
|
add('kitty @launch e', all_words('exe1', 'exe2'))
|
||||||
|
|
||||||
for cmd, tests, result in zip(all_cmds, all_tests, run_tool()):
|
for cmd, tests, result in zip(all_cmds, all_tests, run_tool()):
|
||||||
|
|||||||
@ -81,9 +81,10 @@ func serialize(completions *Completions, f *markup.Context, screen_width int) ([
|
|||||||
fmt.Fprintln(&output, "shift words")
|
fmt.Fprintln(&output, "shift words")
|
||||||
fmt.Fprintln(&output, "(( CURRENT-- ))")
|
fmt.Fprintln(&output, "(( CURRENT-- ))")
|
||||||
}
|
}
|
||||||
fmt.Fprintln(&output, "_normal -p ", utils.QuoteStringForSH(completions.Delegate.Command))
|
service := utils.QuoteStringForSH(completions.Delegate.Command)
|
||||||
return []byte(output.String()), nil
|
fmt.Fprintln(&output, "words[1]="+service)
|
||||||
}
|
fmt.Fprintln(&output, "_normal -p", service)
|
||||||
|
} else {
|
||||||
for _, mg := range completions.Groups {
|
for _, mg := range completions.Groups {
|
||||||
cmd := strings.Builder{}
|
cmd := strings.Builder{}
|
||||||
cmd.WriteString("compadd -U -J ")
|
cmd.WriteString("compadd -U -J ")
|
||||||
@ -117,6 +118,7 @@ func serialize(completions *Completions, f *markup.Context, screen_width int) ([
|
|||||||
}
|
}
|
||||||
fmt.Fprintln(&output, cmd.String(), ";")
|
fmt.Fprintln(&output, cmd.String(), ";")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// debugf("%#v", output.String())
|
// debugf("%#v", output.String())
|
||||||
return []byte(output.String()), nil
|
return []byte(output.String()), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user