-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpassword-store-ssh
More file actions
50 lines (41 loc) · 1.21 KB
/
password-store-ssh
File metadata and controls
50 lines (41 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# completion file for bash
# Copyright (C) 2014 Marc Blumenfrucht and Anne Jan Brouwer
# Copyright (C) 2012 Jason A. Donenfeld <Jason@zx2c4.com> and
# Brian Mattern <rephorm@rephorm.com>. All Rights Reserved.
# This file is licensed under the GPLv2+. Please see LICENSE for more information.
_pass_complete_entries () {
prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store/}"
suffix=".gpg"
autoexpand=${1:-0}
local IFS=$'\n'
local items=($(compgen -f $prefix$cur))
for item in ${items[@]}; do
if [[ $item == $prefix.* ]]; then
continue
fi
# if there is a unique match, and it is a directory with one entry
# autocomplete the subentry as well (recursively)
if [[ ${#items[@]} -eq 1 && $autoexpand -eq 1 ]]; then
while [[ -d $item ]]; do
local subitems=($(compgen -f "$item/"))
if [[ ${#subitems[@]} -eq 1 ]]; then
item="${subitems[0]}"
else
break
fi
done
fi
# append / to directories
[[ -d $item ]] && item="$item/"
item="${item%$suffix}"
COMPREPLY+=("${item#$prefix}")
done
}
_pass()
{
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY+=($(compgen -W "${commands}" -- ${cur}))
_pass_complete_entries 1
}
complete -o filenames -o nospace -F _pass passh