_ksi_completions() {
    builtin local src
    builtin local limit
    # Send all words up to the word the cursor is currently on
    builtin let limit=1+$COMP_CWORD
    src=$(builtin printf "%s\n" "${COMP_WORDS[@]:0:$limit}" | builtin command kitten __complete__ bash)
    if [[ $? == 0 ]]; then
        builtin eval "${src}"
    fi
}

builtin complete -F _ksi_completions kitty
builtin complete -F _ksi_completions edit-in-kitty
builtin complete -F _ksi_completions clone-in-kitty
builtin complete -F _ksi_completions kitten
