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

clusterctl: Support autocompletion for the fish shell #10723

Closed
guettli opened this issue Jun 5, 2024 · 5 comments
Closed

clusterctl: Support autocompletion for the fish shell #10723

guettli opened this issue Jun 5, 2024 · 5 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@guettli
Copy link
Contributor

guettli commented Jun 5, 2024

What would you like to be added (User Story)?

As an operator, if would like to have shell autocompletion for clusterctl because this is convenient.

Detailed Description

In bash (configured via docs about completion) clusterctl get kubeTABTAB will autocomplete to clusterctl get kubeconfig.

It would be nice to have this for the fish shell, too.

According to the source fish is already suported. But I guess it is not provided via homebrew.

Here my fish completions:

❯ find .linuxbrew/share/fish/
.linuxbrew/share/fish/
.linuxbrew/share/fish/vendor_completions.d
.linuxbrew/share/fish/vendor_completions.d/atuin.fish
.linuxbrew/share/fish/vendor_completions.d/delta.fish
.linuxbrew/share/fish/vendor_completions.d/hcloud.fish
.linuxbrew/share/fish/vendor_completions.d/k9s.fish
.linuxbrew/share/fish/vendor_completions.d/golangci-lint.fish
.linuxbrew/share/fish/vendor_completions.d/kubectl.fish
.linuxbrew/share/fish/vendor_completions.d/chezmoi.fish
.linuxbrew/share/fish/vendor_completions.d/oras.fish
.linuxbrew/share/fish/vendor_completions.d/rg.fish
.linuxbrew/share/fish/vendor_completions.d/gh.fish
.linuxbrew/share/fish/vendor_completions.d/yq.fish
.linuxbrew/share/fish/vendor_completions.d/starship.fish
.linuxbrew/share/fish/vendor_completions.d/helm.fish
.linuxbrew/share/fish/vendor_completions.d/tilt.fish
.linuxbrew/share/fish/vendor_completions.d/fd.fish
.linuxbrew/share/fish/vendor_completions.d/stern.fish
.linuxbrew/share/fish/vendor_completions.d/kind.fish
.linuxbrew/share/fish/vendor_completions.d/brew.fish
.linuxbrew/share/fish/vendor_conf.d
.linuxbrew/share/fish/vendor_conf.d/direnv.fish

Anything else you would like to add?

I can have a look at this, too, and create a PR. Just tell me.

Label(s) to be applied

/kind feature

/area clusterctl

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. needs-priority Indicates an issue lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 5, 2024
@fabriziopandini fabriziopandini added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/backlog Higher priority than priority/awaiting-more-evidence. triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Jun 5, 2024
@k8s-ci-robot k8s-ci-robot removed needs-priority Indicates an issue lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 5, 2024
@chrischdi
Copy link
Member

I can have a look at this, too, and create a PR. Just tell me.

@guettli : feel free to assign to yourself and go ahead.

@kranurag7
Copy link
Contributor

this was done here via this patch #9950 I am using clusterctl 1.7.2 version and the completion is there. (missing in 1.6 series as it was not cherry-picked)

You can use fish completion using clusterctl completion fish | source

To have completion for every shell environment, you'll have to save it on your ~/.config/fish/config.fish you can use the following:

if command -v clusterctl &> /dev/null
    clusterctl completion fish | source
end

@kranurag7
Copy link
Contributor

I created a patch in homebrew repo to have completion enabled by default for fish shell as well when you use brew install clusterctl

ref: Homebrew/homebrew-core#174030

@guettli
Copy link
Contributor Author

guettli commented Jun 10, 2024

@kranurag7 thank you very much. After install clusterctl via brew again, it worked out of the box. No need to configure autocomplete manually.

❯ find /home/linuxbrew/.linuxbrew/share/fish/| grep clusterctl
/home/linuxbrew/.linuxbrew/share/fish/vendor_completions.d/clusterctl.fish

issue is solved.

I use that in my config.fish:

...
if status is-interactive
    # Commands to run in interactive sessions can go here


    /home/linuxbrew/.linuxbrew/bin/brew shellenv | source

    # Autocomplete for commands installed via brew.
    eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv)
    if test -d (brew --prefix)"/share/fish/completions"
        set -p fish_complete_path (brew --prefix)/share/fish/completions
    end

    if test -d (brew --prefix)"/share/fish/vendor_completions.d"
        set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
    end
...

This way, the autocomplete gets installed automatically (if provided by the application installed via brew).

@guettli guettli closed this as completed Jun 10, 2024
@sbueringer
Copy link
Member

Nice! Thx @kranurag7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

6 participants