1
# completion file for bash
3
# Copyright (C) 2012 Jason A. Donenfeld <Jason@zx2c4.com> and
4
# Brian Mattern <rephorm@rephorm.com>. All Rights Reserved.
5
# This file is licensed under the GPLv2+. Please see COPYING for more information.
7
_pass_complete_entries () {
8
prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store/}"
13
local items=($(compgen -f $prefix$cur))
14
for item in ${items[@]}; do
15
if [[ $item == $prefix.* ]]; then
19
# if there is a unique match, and it is a directory with one entry
20
# autocomplete the subentry as well (recursively)
21
if [[ ${#items[@]} -eq 1 && $autoexpand -eq 1 ]]; then
22
while [[ -d $item ]]; do
23
local subitems=($(compgen -f "$item/"))
24
if [[ ${#subitems[@]} -eq 1 ]]; then
32
# append / to directories
33
[[ -d $item ]] && item="$item/"
35
item="${item%$suffix}"
36
COMPREPLY+=("${item#$prefix}")
40
_pass_complete_keys () {
43
which $GPG >/dev/null || GPG=gpg
44
# Extract names and email addresses from gpg --list-keys
45
local keys="$($GPG --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')"
46
COMPREPLY+=($(compgen -W "${keys}" -- ${cur}))
52
local cur="${COMP_WORDS[COMP_CWORD]}"
53
local commands="init ls show insert generate edit rm git help version"
54
if [[ $COMP_CWORD -gt 1 ]]; then
55
case "${COMP_WORDS[1]}" in
57
COMPREPLY+=($(compgen -W "-e --reencrypt" -- ${cur}))
61
_pass_complete_entries
64
COMPREPLY+=($(compgen -W "-c --clip" -- ${cur}))
65
_pass_complete_entries 1
68
COMPREPLY+=($(compgen -W "-e --echo -m --multiline -f --force" -- ${cur}))
69
_pass_complete_entries
72
COMPREPLY+=($(compgen -W "-n --no-symbols -c --clip -f --force" -- ${cur}))
73
_pass_complete_entries
76
COMPREPLY+=($(compgen -W "-r --recursive -f --force" -- ${cur}))
77
_pass_complete_entries
80
COMPREPLY+=($(compgen -W "init push pull config log reflog" -- ${cur}))
84
COMPREPLY+=($(compgen -W "${commands}" -- ${cur}))
85
_pass_complete_entries 1
89
complete -o filenames -o nospace -F _pass pass