mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-22 20:17:45 +03:00
Completion for bash
This commit is contained in:
parent
933cced76c
commit
f36a9fffa3
14
completion/bash/kitty.sh
Normal file
14
completion/bash/kitty.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
kitty_completions() {
|
||||||
|
local src
|
||||||
|
local limit
|
||||||
|
# Send all words up to the word the cursor is currently on
|
||||||
|
let limit=1+$COMP_CWORD
|
||||||
|
src=$(printf "%s\n" "${COMP_WORDS[@]: 0:$limit}" | kitty +complete bash)
|
||||||
|
if [[ $? == 0 ]]; then
|
||||||
|
eval ${src}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F kitty_completions kitty
|
@ -44,6 +44,13 @@ def zsh_input_parser(data):
|
|||||||
return words, new_word
|
return words, new_word
|
||||||
|
|
||||||
|
|
||||||
|
@input_parser
|
||||||
|
def bash_input_parser(data):
|
||||||
|
new_word = data.endswith('\n\n')
|
||||||
|
words = data.rstrip().splitlines()
|
||||||
|
return words, new_word
|
||||||
|
|
||||||
|
|
||||||
@output_serializer
|
@output_serializer
|
||||||
def zsh_output_serializer(ans):
|
def zsh_output_serializer(ans):
|
||||||
lines = []
|
lines = []
|
||||||
@ -59,6 +66,16 @@ def zsh_output_serializer(ans):
|
|||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
@output_serializer
|
||||||
|
def bash_output_serializer(ans):
|
||||||
|
lines = []
|
||||||
|
for matches in ans.match_groups.values():
|
||||||
|
for word in matches:
|
||||||
|
lines.append('COMPREPLY+=({})'.format(shlex.quote(word)))
|
||||||
|
# debug('\n'.join(lines))
|
||||||
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
def completions_for_first_word(ans, prefix, entry_points, namespaced_entry_points):
|
def completions_for_first_word(ans, prefix, entry_points, namespaced_entry_points):
|
||||||
cmds = ['@' + c for c in cmap]
|
cmds = ['@' + c for c in cmap]
|
||||||
ans.match_groups['Entry points'] = {
|
ans.match_groups['Entry points'] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user