Skip to content

Commit

Permalink
Add bash-completion script
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonVanAssche committed Apr 21, 2024
1 parent 82b0db3 commit 7aec52f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/bashpass-completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

__bashpass_completion() {
local cur_word="${COMP_WORDS[COMP_CWORD]}"
local prev_word="${COMP_WORDS[COMP_CWORD-1]}"
COMPREPLY=()

if [[ "${cur_word}" == -* ]]; then
while IFS= read -r; do
COMPREPLY+=( "${REPLY}" )
done < <(compgen -W "$(bashpass --help)" -- "${COMP_WORDS[COMP_CWORD]}")
fi

if [[ "${prev_word}" == '-S' || "${prev_word}" == '--sync' ]]; then
# shellcheck disable=SC2207
COMPREPLY=( $(compgen -W 'download upload' -- "${COMP_WORDS[COMP_CWORD]}") )
fi
}

complete -F __bashpass_completion bashpass

0 comments on commit 7aec52f

Please sign in to comment.