Bash
Bazel comes with a Bash completion script. If you installed Bazel:-
From the APT repository, then you’re done — the Bash completion script is
already installed in
/etc/bash_completion.d. -
From Homebrew, then you’re done — the Bash completion script is
already installed in
$(brew --prefix)/etc/bash_completion.d. -
From the installer downloaded from GitHub, then:
-
Locate the absolute path of the completion file. The installer copied it
to the
bindirectory. Example: if you ran the installer with--user, this will be$HOME/.bazel/bin. If you ran the installer as root, this will be/usr/local/lib/bazel/bin. -
Do one of the following:
-
Either copy this file to your completion directory (if you have
one).
Example: on Ubuntu this is the
/etc/bash_completion.ddirectory. -
Or source the completion file from Bash’s RC file.
Add a line similar to the one below to your
~/.bashrc(on Ubuntu) or~/.bash_profile(on macOS), using the path to your completion file’s absolute path:
-
Either copy this file to your completion directory (if you have
one).
Example: on Ubuntu this is the
-
Locate the absolute path of the completion file. The installer copied it
to the
-
Via bootstrapping, then:
-
Emit the completion script into a file:
-
Do one of the following:
-
Copy this file to your completion directory, if you have
one.
Example: on Ubuntu this is the
/etc/bash_completion.ddirectory -
Copy it somewhere on your local disk, such as to
$HOME, and source the completion file from Bash’s RC file. Add a line similar to the one below to your~/.bashrc(on Ubuntu) or~/.bash_profile(on macOS), using the path to your completion file’s absolute path:
-
Copy this file to your completion directory, if you have
one.
Example: on Ubuntu this is the
-
Emit the completion script into a file:
Zsh
Bazel comes with a Zsh completion script. If you installed Bazel:-
From the APT repository, then you’re done — the Zsh completion script is
already installed in
/usr/share/zsh/vendor-completions.If you have a heavily customized
.zshrcand the autocomplete does not function, try one of the following solutions: Add the following to your.zshrc:or Follow the instructions here If you are usingoh-my-zsh, you may want to install and enable thezsh-autocompleteplugin. If you’d prefer not to, use one of the solutions described above. -
From Homebrew, then you’re done — the Zsh completion script is
already installed in
$(brew --prefix)/share/zsh/site-functions. -
From the installer downloaded from GitHub, then:
-
Locate the absolute path of the completion file. The installer copied it
to the
bindirectory. Example: if you ran the installer with--user, this will be$HOME/.bazel/bin. If you ran the installer as root, this will be/usr/local/lib/bazel/bin. -
Add this script to a directory on your
$fpath:You may have to callrm -f ~/.zcompdump; compinitthe first time to make it work. -
Optionally, add the following to your .zshrc.
-
Locate the absolute path of the completion file. The installer copied it
to the