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 dc79bcb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/bashpass-completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# shellcheck disable=SC2207
__bashpass_completion() {
local cur_word="${COMP_WORDS[COMP_CWORD]}"
local prev_word="${COMP_WORDS[COMP_CWORD-1]}"
local options='--help -h --add -a --copy -c --delete -d --show -s --update -u --list -l --sync -S'
COMPREPLY=()

if [[ "${cur_word}" == -* ]]; then
COMPREPLY+=( $(compgen -W "${options}" -- "${COMP_WORDS[COMP_CWORD]}") )
fi

case "${prev_word}" in
'-a'|'--add'|'-c'|'--copy'|'-d'|'--delete'|'-s'|'--show'|'-u'|'--update')
COMPREPLY=(
$(compgen -W "$(bashpass --list | tail -n +2)" -- "${COMP_WORDS[COMP_CWORD]}")
)
;;
'S'|'--sync')
COMPREPLY=(
$(compgen -W 'download upload' -- "${COMP_WORDS[COMP_CWORD]}")
)
;;
esac
}

complete -F __bashpass_completion bashpass

0 comments on commit dc79bcb

Please sign in to comment.