clink-completions icon indicating copy to clipboard operation
clink-completions copied to clipboard

Add completions for `gh` (GitHub.cli)

Open vladimir-kotikov opened this issue 7 years ago • 8 comments

hub is a command-line wrapper for git that makes you better at GitHub. See https://hub.github.com for CLI examples

vladimir-kotikov avatar Sep 19 '16 11:09 vladimir-kotikov

hub is deprecated and replaced by gh. I'll explore cost/feasibility of adding completions for gh.

chrisant996 avatar Nov 18 '23 19:11 chrisant996

I came here hoping to find a gh completion file for clink. I tried getting a lua specialised GPT to translate the zsh _gh file into lua, but it said that it was too complicated.

https://chat.openai.com/share/99a47c73-72bc-49a2-b1a2-9d86b9c60da1

eggbean avatar Jan 20 '24 04:01 eggbean

I have a prototype script for gh completions. I haven't had time to test it or fill in the gaps.

Would you like to mess around with testing it and filling in stuff, or at least filing issues for what's missing or wrong?

I can make a topic branch for working on the gh completions, if you'd like.

chrisant996 avatar Jan 20 '24 04:01 chrisant996

I created a gh_completions topic branch.

It has gh.lua which is the prototype script.

chrisant996 avatar Jan 20 '24 04:01 chrisant996

Would you like to mess around with testing it and filling in stuff, or at least filing issues for what's missing or wrong?

Sure. I'll start using it and see if I come across any problems.

eggbean avatar Jan 20 '24 05:01 eggbean

@eggbean How have the gh completions been working for you? Any feedback, things to fix or improve?

chrisant996 avatar Mar 10 '24 17:03 chrisant996

Yes, it's been working well for me, thanks. I have not encountered any bugs or problems.

I haven't tried every subcommand extensively, but I have been using a few subcommands that I had never used before, as I didn't know they even existed until using these completions.

(I still haven't been able to combine these completion suggestions with the repeated tab cycling, in a similar way that is possible in zsh, though)

eggbean avatar Mar 12 '24 07:03 eggbean

(I still haven't been able to combine these completion suggestions with the repeated tab cycling, in a similar way that is possible in zsh, though)

@eggbean Can you give an example?

chrisant996 avatar Mar 12 '24 07:03 chrisant996

(I still haven't been able to combine these completion suggestions with the repeated tab cycling, in a similar way that is possible in zsh, though)

@eggbean I don't understand what is meant by that. Can you give an example? I can probably explain or show how.

Everything I've tried has worked great.

chrisant996 avatar May 04 '24 02:05 chrisant996

Sorry, I'll get back to you soon once I figure out what I meant.

eggbean avatar May 04 '24 02:05 eggbean

(I still haven't been able to combine these completion suggestions with the repeated tab cycling, in a similar way that is possible in zsh, though)

@eggbean Maybe you meant one of these?

  • Do you want the dark gray "auto suggestion" text to only show suggestions from available completions and never from history? clink set autosuggest.strategy completion (that would be pretty non-useful though; it might be better to just turn off autosuggest entirely in that case).
  • Do you want Tab to cycle through completions? Either set Clink to use Windows key bindings instead of Bash key bindings (clink set clink.default_bindings windows) or set up bindings in your .inputrc file such as:
    "\C-I":    old-menu-complete
    "\e[Z":    old-menu-complete-backward
    

chrisant996 avatar May 07 '24 17:05 chrisant996

@eggbean Oh, I think what you're looking for ("in a similar way that is possible in zsh") might be bash's show-all-if-ambiguous config variable.

In the .inputrc file:

# Show matches if there's more than one (in complete, menu-complete, old-menu-complete).
set show-all-if-ambiguous    on
# Bind TAB to either menu-complete or old-menu-complete, depending on your preference.
"\C-I":    menu-complete
"\e[Z":    menu-complete-backward

But trying to figure out what you're referring to led me to find that in Clink the menu-complete commands weren't updated to respect the completion-auto-query-items config variable. So a fix for that is coming in v1.6.14 (probably in a week or two).

chrisant996 avatar May 08 '24 17:05 chrisant996

@eggbean I think that the outstanding issue about "combine these completion suggestions with the repeated tab cycling, in a similar way that is possible in zsh" is not about the gh argmatcher, and is instead about how to configure the tab completion command(s) to behave similarly to zsh for all completion in general.

I'm going to go ahead and publish a new release for the clink-completions repo.

chrisant996 avatar May 14 '24 02:05 chrisant996

Completions for gh were added in commit 651b979b4b07f3c4ecb104fdb0209f8a3b39d807.

chrisant996 avatar May 14 '24 02:05 chrisant996