Skip to content

Commit

Permalink
fix: improve the completion settings suggested in `aqua completion --…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
akinomyoga authored Nov 27, 2024
1 parent 61bb9d3 commit 46013b8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/cli/completion/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`,
Expand Down

0 comments on commit 46013b8

Please sign in to comment.