Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd: Add direct shell completion to the default owner #382

Open
su8ru opened this issue Jun 24, 2024 · 6 comments
Open

cd: Add direct shell completion to the default owner #382

su8ru opened this issue Jun 24, 2024 · 6 comments

Comments

@su8ru
Copy link

su8ru commented Jun 24, 2024

Currently, we can still use the defaults.owner option to cd <repo name>, but shell completion always prompts github.com:<owner>/<repo name>.

So it would be more convenient to use the defauts.owner option to cd directly in completion as well.

@siketyan
Copy link
Owner

siketyan commented Jun 24, 2024

@su8ru

Actually, shell completion of ghr works without running ghr itself. This means the completion never know the value of defaults.owner. We need a dynamic completion feature on clap, the CLI library ghr use, which is a known issue: clap-rs/clap#1232 and #298. Thus this will be a long travel.

We still offer completing repositories without typing owner at least i.e. when you type ghr<Tab> it completes github.com/siketyan/ghr if you set defaults.owner = "siketyan". Let me know if this doesn't work on your shell environment.

@su8ru
Copy link
Author

su8ru commented Jun 25, 2024

Thanks, I understand this is a challenging issue.

By the way, the ghr<TAB> completion doesn't work on my zsh 5.9.
Of course I have shell extension and completion installed.

if type "ghr" > /dev/null 2>&1; then
  source <(ghr shell bash)
  source <(ghr shell bash --completion)
fi

@s3i7h
Copy link
Contributor

s3i7h commented Jun 26, 2024

@su8ru could you make a reproduction repo? I'm using zsh 5.9 too but can't reproduce the problem :(
image

@siketyan
Copy link
Owner

@s3i7h Sorry for causing misunderstanding, I mean we can complete name of repositories by typing their name (without owner part).

@su8ru I will investigate it on bash/zsh per I usually use fish 🐟

@s3i7h
Copy link
Contributor

s3i7h commented Jun 26, 2024

I understood what you meant by ghr<TAB> which was actually ghr cd ghr<TAB> or other subcommands. Seems to me that zsh doesn't match completions arbitrary (*ghr*), but from the frontmost only (ghr*). I use z4h, which uses fzf underneath, to overcome this issue, so if you ghr cd <TAB> and then type ghr, it's filtered properly.

image

I still don't follow though. We don't rely completely on ghr when completing a command but we do call ghr sub-commands on the fly, so implementing such feature is already feasible at this moment. (Although I'm not too supportive about it, because you'll need a new subcommand dedicated for listing completion options.)

https://github.com/siketyan/ghr/blob/main/resources/shell/bash/ghr-completion.bash#L11-L35
image

@siketyan
Copy link
Owner

@s3i7h
You are absolutely right, completion itself doesn't load config but it uses ghr list internally so that we can load config there. For the initial improvement I added fuzzy searching as ghr search command and changed the shell completion to use that instead.

The changes will be released in v0.4.3.

@su8ru
The new release has a fuzzy search feature so will solve the problem that bash/zsh completion only completes with prefix match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants