From 46013b82ec1106b06355f7cecbf6385d3d20b99c Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 28 Nov 2024 06:18:46 +0900 Subject: [PATCH] fix: improve the completion settings suggested in `aqua completion --help` (#3297) * fix: suggest ".bashrc" and ".zshrc" for completion setting The current help text suggests adding the completion settings in .bash_profile and .zprofile, but .bash_profile and .zprofile are loaded only in login shell sessions. They are not loaded in (non-login) interactive sessions started inside the login shells, and thus the completion would be disabled in non-login interactive sessions. In general, .bash_profile and .zprofile should only contain the settings that are automatically inherited by the child processes or the global user settings in the operating system. The interactive settings should be put in .bashrc and .zshrc. In this patch, we suggest .bashrc and .zshrc instead of .bash_profile and .zprofile, respectively. * fix: fix the example of a completion setting for Bash 3 The source builtin in Bash 3.* does not support reading from a pipe, so `source <(command)` fails silently. `eval "$(command)"` works in all versions of Bash. * style: make the boundaries of shells outstanding --- pkg/cli/completion/command.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cli/completion/command.go b/pkg/cli/completion/command.go index 743163e7a..6c806b740 100644 --- a/pkg/cli/completion/command.go +++ b/pkg/cli/completion/command.go @@ -21,19 +21,19 @@ Source the output to enable completion. e.g. -.bash_profile +# .bashrc if command -v aqua &> /dev/null; then - source <(aqua completion bash) + eval "$(aqua completion bash)" fi -.zprofile +# .zshrc if command -v aqua &> /dev/null; then source <(aqua completion zsh) fi -fish +# fish aqua completion fish > ~/.config/fish/completions/aqua.fish `,