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

Move completions file to ~/.local/share/bash-completion/completions #905

Merged
merged 9 commits into from
Aug 31, 2024
8 changes: 5 additions & 3 deletions APP-MANAGER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

AMVERSION="8.1"
AMVERSION="8.1.1"

# Determine main repository and branch
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
Expand Down Expand Up @@ -303,8 +303,10 @@ function _completion_lists() {
}

# BASH AND ZSH COMPLETION
completion_file="${ZDOTDIR:-$HOME}"/.bash_completion
if ! grep -qo " $AMCLI$" "$completion_file" >/dev/null 2>&1; then
completion_file="$DATADIR/bash-completion/completions/am"
mkdir -p "$DATADIR/bash-completion/completions" || exit 1
[ -f "$HOME"/.bash_completion ] && sed -i "/ $AMCLI$/d" "$HOME"/.bash_completion
if ! grep -o " $AMCLI$" "$completion_file" >/dev/null 2>&1; then
echo "complete -W \"\$(cat $AMDATADIR/list 2>/dev/null)\" $AMCLI" >> "$completion_file"
if [ -f "${ZDOTDIR:-$HOME}"/.zshrc ] && echo "$SHELL" | grep -q "zsh"; then
cat <<-HEREDOC >> "${ZDOTDIR:-$HOME}"/.zshrc
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,7 @@ EXTRA: The behavior of this option can be tested in a completely standalone way

__________________________________________________________________________
### How to enable bash completion
From version 8, BASH/ZSH completion is enabled in "AM" and "AppMan" by default.

A file $HOME/.bash_completion will be created, or if it exists, it will be patched to allow the command `am` or `appman` to read arguments from the related "list" of arguments, or other lists, to made it more extensible.
**From version 8**, BASH/ZSH completion is enabled in "AM" and "AppMan" by default. and **from version 8.1.1** a file $HOME/.local/share/bash-completion/completions/am (and no more $HOME/.bash_completion) will be created and shared by both `am` and `appman` to read arguments from the related "list" of arguments, or other lists, to made it more extensible.

Before version 8, in "AM" were created a "/etc/bash_completion.d/am-completion.sh" using a dedicated option.

Expand Down