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.
12 # If you use multiple repositories, you can configure completion like this:
14 # compdef _pass workpass
15 # zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
17 # PASSWORD_STORE_DIR=$HOME/work/pass pass $@
23 if (( CURRENT > 2)); then
25 # Set the context for the subcommand.
26 curcontext="${curcontext%:*:*}:pass-$cmd"
27 # Narrow the range of words we are looking at to exclude `pass'
30 # Run the completion for the subcommand
34 "-p[gpg-id will only be applied to this subfolder]" \
35 "--path[gpg-id will only be applied to this subfolder]"
39 _pass_complete_entries_with_subdirs
43 "-e[echo password to console]" \
44 "--echo[echo password to console]" \
46 "--multiline[multiline]"
47 _pass_complete_entries_with_subdirs
51 "-n[don't include symbols in password]" \
52 "--no-symbols[don't include symbols in password]" \
53 "-c[copy password to the clipboard]" \
54 "--clip[copy password to the clipboard]" \
55 "-f[force overwrite]" \
56 "--force[force overwrite]" \
57 "-i[replace first line]" \
58 "--in-place[replace first line]"
59 _pass_complete_entries_with_subdirs
64 "--force[force rename]"
65 _pass_complete_entries_with_subdirs
69 "-f[force deletion]" \
70 "--force[force deletion]" \
71 "-r[recursively delete]" \
72 "--recursive[recursively delete]"
73 _pass_complete_entries_with_subdirs
78 "init:Initialize git repository"
79 "push:Push to remote repository"
80 "pull:Pull from remote repository"
81 "config:Show git config"
83 "reflog:Show git reflog"
85 _describe -t commands 'pass git' subcommands
94 "init:Initialize new password storage"
96 "find:Find password files or directories based on pattern"
97 "grep:Search inside decrypted password files for matching pattern"
98 "show:Decrypt and print a password"
99 "insert:Insert a new password"
100 "generate:Generate a new password using pwgen"
101 "edit:Edit a password with \$EDITOR"
102 "mv:Rename the password"
103 "cp:Copy the password"
104 "rm:Remove the password"
105 "git:Call git on the password store"
106 "version:Output version information"
107 "help:Output help message"
109 _describe -t commands 'pass' subcommands
111 "--version[Output version information]" \
112 "--help[Output help message]"
119 "-c[put it on the clipboard]" \
120 "--clip[put it on the clipboard]"
121 _pass_complete_entries
123 _pass_complete_entries_helper () {
126 zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
127 _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##' -e 's#\\#\\\\#g' -e 's#:#\\:#g' | sort):-""}
130 _pass_complete_entries_with_subdirs () {
131 _pass_complete_entries_helper
134 _pass_complete_entries () {
135 _pass_complete_entries_helper -type f
138 _pass_complete_keys () {
140 # Extract names and email addresses from gpg --list-keys
141 _values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')