4 # Copyright (C) 2012 - 2014:
5 # Johan Venant <jvenant@invicem.pro>
6 # Brian Mattern <rephorm@rephorm.com>
7 # Jason A. Donenfeld <Jason@zx2c4.com>.
9 # This file is licensed under the GPLv2+. Please see COPYING for more information.
14 if (( CURRENT > 2)); then
16 # Set the context for the subcommand.
17 curcontext="${curcontext%:*:*}:pass-$cmd"
18 # Narrow the range of words we are looking at to exclude `pass'
21 # Run the completion for the subcommand
25 "-p[gpg-id will only be applied to this subfolder]" \
26 "--path[gpg-id will only be applied to this subfolder]"
30 _pass_complete_entries_with_subdirs
34 "-e[echo password to console]" \
35 "--echo[echo password to console]" \
37 "--multiline[multiline]"
38 _pass_complete_entries_with_subdirs
42 "-n[don't include symbols in password]" \
43 "--no-symbols[don't include symbols in password]" \
44 "-c[copy password to the clipboard]" \
45 "--clip[copy password to the clipboard]" \
46 "-f[force overwrite]" \
47 "--force[force overwrite]" \
48 "-i[replace first line]" \
49 "--in-place[replace first line]"
50 _pass_complete_entries_with_subdirs
55 "--force[force rename]"
56 _pass_complete_entries_with_subdirs
60 "-f[force deletion]" \
61 "--force[force deletion]" \
62 "-r[recursively delete]" \
63 "--recursive[recursively delete]"
64 _pass_complete_entries_with_subdirs
69 "init:Initialize git repository"
70 "push:Push to remote repository"
71 "pull:Pull from remote repository"
72 "config:Show git config"
74 "reflog:Show git reflog"
76 _describe -t commands 'pass git' subcommands
85 "init:Initialize new password storage"
87 "find:Find password files or directories based on pattern"
88 "grep:Search inside decrypted password files for matching pattern"
89 "show:Decrypt and print a password"
90 "insert:Insert a new password"
91 "generate:Generate a new password using pwgen"
92 "edit:Edit a password with \$EDITOR"
93 "mv:Rename the password"
94 "cp:Copy the password"
95 "rm:Remove the password"
96 "git:Call git on the password store"
97 "version:Output version information"
98 "help:Output help message"
100 _describe -t commands 'pass' subcommands
102 "--version[Output version information]" \
103 "--help[Output help message]"
110 "-c[put it on the clipboard]" \
111 "--clip[put it on the clipboard]"
112 _pass_complete_entries
114 _pass_complete_entries_helper () {
116 local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
117 _values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' | sort):-""}
120 _pass_complete_entries_with_subdirs () {
121 _pass_complete_entries_helper
124 _pass_complete_entries () {
125 _pass_complete_entries_helper -type f
128 _pass_complete_keys () {
130 # Extract names and email addresses from gpg --list-keys
131 _values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')