Skip to content

Fuzzy autocompletion improvements for shell integration #11644

Closed as not planned

Description

@gorakhargosh

Description of the problem / feature request:

Feature Request:

The shell autocompletion feature for any shell can offload fuzzy completion
of bazel targets to fzf. Consider installing fzf
(go get -u github.com/junegunn/fzf) and run the following
command to see how it works:

bazel test $(bazel query '...' --output label | fzf)

Some visuals:
Test
Benchmark

Could you please integrate the following with
the shell autocompletion scripts if possible?

# individual test selection
$ bazel test $(bazel query 'kind(".*_test", ...)' --output label | fzf)

# individual benchmark selection
$ bazel run --config=release $(bazel query 'kind(".*_binary", filter(".*_benchmark", ...))' --output label | fzf)

# run a selected binary
$ bazel run $(bazel query 'kind(".*_binary", ...)' --output label | fzf)

It'd be wild if the autocompletion scripts did this automatically.
Perhaps by adding key bindings for bazel targets too.

Example key sequences for absolute target path completion:

$ bazel run --config=release //<tab:fzf-complete-binary-target> //<tab:fzf-complete-binary-target>

$ bazel test --config=tsan //<tab:fzf-complete-test-target> //<tab:fzf-complete-test-target>

Example key sequences for relative target path completion:

$ bazel run --config=release <tab:fzf-complete-binary-target-below-current-directory> <tab:fzf-complete-binary-target-below-current-directory>

$ bazel test --config=tsan <tab:fzf-complete-test-target-below-current-directory> <tab:fzf-complete-test-target>

where each target selection list also contains //package/path/... and ... as options to select.

Feature requests: what underlying problem are you trying to solve with this feature?

I've used Bazel for several years and my number 1 feature
request would be making it super convenient for users to use bazel
without having to remember or type large paths. This improves user efficiency.
Multiply that by the number of users and you have a much faster workforce.
It's likely this may also cause people to create fine-grained Bazel dependency
graphs.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Not a bug but a productivity enhancement.

What operating system are you running Bazel on?

Linux, Mac OS X.

What's the output of bazel info release?

release 3.3.0

If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.

N/A

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

N/A

Have you found anything relevant by searching the web?

Another feature request for adding fish shell integration for Bazel.
#11450

Any other information, logs, or outputs that you want to share?

N/A

Activity

  1. added
    area-EngProdBazel CI, infrastructure, bootstrapping, release, and distribution tooling
    team-OSSIssues for the Bazel OSS team: installation, release processBazel packaging, website
    on Jun 29, 2020
  2. srsudar commented on Jan 14, 2021

    @srsudar

    What kind of speed do you get with bazel query? Are those gifs real-time?

    I have a completion that just uses ripgrep to look at BUILD files and matches the name attribute. I know that some projects rely on dynamic rules where that is insufficient and your approach would be better. Every time that I use query it has been slow so I haven't bothered to add support for it.

    With my ripgrep approach I have a script that generates directories I want to search. That then is fed to the fzf command and limits the search scope, which makes it quite fast.

    I found working with bazel slightly tedious before adding fzf. I agree that it is a monumental improvement to the workflow.

  3. added
    P3We're not considering working on this, but happy to review a PR. (No assignee)
    on Feb 8, 2021
  4. github-actions commented on Apr 26, 2023

    @github-actions

    Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

  5. added
    staleIssues or PRs that are stale (no activity for 30 days)
    on Apr 26, 2023
  6. github-actions commented on May 11, 2023

    @github-actions

    This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)area-EngProdBazel CI, infrastructure, bootstrapping, release, and distribution toolingstaleIssues or PRs that are stale (no activity for 30 days)team-OSSIssues for the Bazel OSS team: installation, release processBazel packaging, websitetype: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions