spm

Personal fork of spm (simple password manager)
git clone git@getsh.org:spm.git
Log | Files | Refs | README | LICENSE

commit 470bc8aaf72d461d170b4ac6abae3f6ad2c8f393
parent 46e615cfdaf8ea9181450030177ccdee3df931ad
Author: nmeum <git-nmeum@8pit.net>
Date:   Tue, 25 Mar 2014 10:21:52 +0100

Add primitive bash completions

Diffstat:
Abash_completion | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/bash_completion b/bash_completion @@ -0,0 +1,20 @@ +_tpm() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local cmd="${COMP_WORDS[1]}" + + if [[ "${cmd}" = "insert" ]]; then + _tpm_complete_entries -true + elif [[ "${cmd}" = "show" ]]; then + _tpm_complete_entries -iname '*.gpg' -type f + else + COMPREPLY=($(compgen -W "insert show" -- ${cur})) + fi +} + +_tpm_complete_entries() { + local dir="${TPM_STORE_DIR:-${HOME}/.password-store}" + local files="$(find "${dir}/" $@ -print | sed -e "s^${dir}.^^" -e 's^\.gpg^^' | sort)" + COMPREPLY=($(compgen -W "${files}" -- ${cur})) +} + +complete -F _tpm tpm