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

Add completion troubleshooting guide #4821

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs-ref-conceptual/includes/cli-install-linux-apt.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,5 @@ If your proxy doesn't use basic auth, __remove__ the `[username]:[password]@` po
In order to get the Microsoft signing key and get the package from our repository, your proxy needs to allow HTTPS connections to the following address: `https://packages.microsoft.com.
[!INCLUDE[troubleshoot-wsl.md](troubleshoot-wsl.md)]
[!INCLUDE[linux-completion.md](linux-completion.md)]
2 changes: 2 additions & 0 deletions docs-ref-conceptual/includes/cli-install-linux-dnf.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,5 @@ allow HTTPS connections to the following address:
* `https://packages.microsoft.com`

[!INCLUDE[troubleshoot-wsl.md](troubleshoot-wsl.md)]

[!INCLUDE[linux-completion.md](linux-completion.md)]
4 changes: 4 additions & 0 deletions docs-ref-conceptual/includes/cli-install-linux-tdnf.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ sudo tdnf remove azure-cli
### Remove data

[!INCLUDE [remove-data-boilerplate.md](remove-data-boilerplate.md)]

bebound marked this conversation as resolved.
Show resolved Hide resolved
## Troubleshooting

[!INCLUDE[linux-completion.md](linux-completion.md)]
20 changes: 20 additions & 0 deletions docs-ref-conceptual/includes/linux-completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
author: bebound
ms.author: hanglei
ms.date: 11/29/2024
ms.topic: include
---
### Completion isn't working

For Bash users, the completion script is installed in `/etc/bash_completion.d/azure-cli`. Add the following line to your `~/.bashrc` file, then save and reload your Bash profile:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't /etc/bash_completion.d/azure-cli automatically executed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, this folder is loaded automatically.
At least, on Ubuntu, /etc/bash.bashrc calls /usr/share/bash-completion/bash_completion, which contains

# source compat completion directory definitions
compat_dir=${BASH_COMPLETION_COMPAT_DIR:-/etc/bash_completion.d}
if [[ -d $compat_dir && -r $compat_dir && -x $compat_dir ]]; then
    for i in "$compat_dir"/*; do
        [[ ${i##*/} != @($_backup_glob|Makefile*|$_blacklist_glob) && -f \
        $i && -r $i ]] && . "$i"
    done
fi

When writing the doc and testing tab completion in a Docker image, it doesn't load automatically. So I included it here just in case.

Ref:

Copy link
Member

@jiasli jiasli Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I would suggest adding a "if...":

Suggested change
For Bash users, the completion script is installed in `/etc/bash_completion.d/azure-cli`. Add the following line to your `~/.bashrc` file, then save and reload your Bash profile:
For Bash users, the completion script is installed in `/etc/bash_completion.d/azure-cli`. If it is not automatically executed, add the following line to your `~/.bashrc` file, then save and reload your Bash profile:


```bash
source /etc/bash_completion.d/azure-cli
```

For Zsh users, add the following two lines in your `~/.zshrc` file, then save and reload your Zsh profile:

```zsh
autoload -U +X bashcompinit && bashcompinit
source /etc/bash_completion.d/azure-cli
```
2 changes: 1 addition & 1 deletion docs-ref-conceptual/install-azure-cli-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If you encounter a problem when installing the CLI through Homebrew, here are so

### Completion isn't working

The Homebrew formula of Azure CLI installs a completion file named `az` in the Homebrew-managed completions directory (default location is `/usr/local/etc/bash_completion.d/`). To enable completion, follow Homebrew's instructions [here](https://docs.brew.sh/Shell-Completion).
The Homebrew formula of Azure CLI installs a completion file named `az` in the Homebrew-managed completions directory (default location is `$(brew --prefix)/etc/bash_completion.d/`). To enable completion, follow Homebrew's instructions [here](https://docs.brew.sh/Shell-Completion).

For Zsh, add the following two lines to the bottom of your `.zshrc` file, then save and reload your Zsh profile.

Expand Down