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 22, 2024
1 parent f4a0a9d commit b23a978
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/bashpass-completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/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=()

[[ "${cur_word}" == -* ]] && \
COMPREPLY+=( $(compgen -W "${options}" -- "${COMP_WORDS[COMP_CWORD]}") )

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 b23a978

Please sign in to comment.