bazelisk
bazelisk copied to clipboard
Support bash autocomplete
Since bazelisk downloads entire binaries, autocomplete scripts are not accessible. bazelisk could potentially also download the autocomplete scripts to a predetermined location to make it easier invoke.
+1, this will be excellent to have.
I suppose you can do this manually with instructions from https://docs.bazel.build/versions/master/completion.html#bash
$ bazel build //scripts:bazel-complete.bash
$ cp bazel-bin/scripts/bazel-complete.bash /etc/bash_completion.d/bazelisk
# new shell
$ bazelisk <TAB>
analyze --nodeep_execroot
analyze-profile --noexoblaze
aquery --noexpand_configs_in_place
--batch --noexperimental_oom_more_eagerly
--batch_cpu_scheduling --noidle_server_tasks
--blazerc= --noignore_all_rc_files
..
yeah that's what i ended up doing... I was hoping something like a bundled bash completion script that bazelisk
could provide, but it's not super blocking
I would love to have this myself, but currently don't have time to implement this - if someone wants to contribute a PR, I would be very happy to review it.
I'll take a stab at this when I have time over the next few days.
@sudoforge Thanks! If you could find a solution that also works with zsh completions, I'd be extra grateful 😊 (I was a long-time bash user, but since macOS Catalina switched to zsh by default, I gave it a try and stuck with it.)
I'll be looking to add completion for all shells that Bazel supports -- off the top of my head, I think that's just Bash and ZSH.
+1 would be super useful to have
FWIW this is done now for zsh on Homebrew installs of bazelisk: https://github.com/bazelbuild/homebrew-tap/pull/89
I've got it working on my mac using zsh but it's painfully slow. Are others experiencing the same?
I've got it working on my mac using zsh but it's painfully slow. Are others experiencing the same?
Having done some comparisons between bazel and bazelisk using zsh completion on my mac, bazelisk is orders of magnitude slower.
Having done some comparisons between bazel and bazelisk using zsh completion on my mac, bazelisk is orders of magnitude slower.
I wonder if https://github.com/bazelbuild/bazelisk/pull/248 would improve this
I've given some thought to this and will be sending a PR out in the next few days with a proposed solution.
... two years later. Oh, life, how structured you are. :)
Any update here? I'd be glad to help if I can.
@sudoforge Is this still something you're planning to open?
Here's the workaround I'm using in case this is useful to anybody else.
curl -fsSL https://raw.githubusercontent.com/bazelbuild/bazel/$(cat .bazelversion)/scripts/bazel-complete-header.bash >> ~/.bashrc
curl -fsSL https://raw.githubusercontent.com/bazelbuild/bazel/$(cat .bazelversion)/scripts/bazel-complete-template.bash >> ~/.bashrc
bazel help completion >> ~/.bashrc
I was looking at this briefly, and my assumption as to what needs to be done:
- Update DownloadRelease to also fetch the auto-complete scripts
- To get the auto-complete scripts, the source needs to be downloaded (e.g. https://releases.bazel.build/6.0.0/release/bazel_6.0.0.tar.gz), and for simplicity probably just extract the entire "scripts/" directory (which includes bazel-complete-header.bash and such, and other auto-completes).
- Make that scripts/ sub-directory available in a deterministic place, so switching bazel versions also switches the underlying scripts
Seem reasonable to others?