summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/pass.zsh-completion151
1 files changed, 92 insertions, 59 deletions
diff --git a/contrib/pass.zsh-completion b/contrib/pass.zsh-completion
index bfe5dca..ef52976 100644
--- a/contrib/pass.zsh-completion
+++ b/contrib/pass.zsh-completion
@@ -3,76 +3,109 @@
# This file is under the GPLv2+ license.
# Heavily based on http://zsh.sf.net/Guide/zshguide06.html#l177
# And Frédéric Perrin article http://tar-jx.bz/notes/zsh-completion.html
-# Johan Venant, September 2012
+# Originally by Johan Venant, September 2012
+# Modified substantially by Brian Mattern, September 2012
-_pass () {
- local cmd
- if (( CURRENT > 2)); then
- cmd=${words[2]}
- # Set the context for the subcommand.
- curcontext="${curcontext%:*:*}:pass-$cmd"
- # Narrow the range of words we are looking at to exclude `pass'
- (( CURRENT-- ))
- shift words
- # Run the completion for the subcommand
- (( $+functions[_pass_cmd_$cmd] )) && _pass_cmd_$cmd
-
- else
- _values 'command' \
- "init[Initialize new password storage]" \
- "ls[subfolder List names of passwords]" \
- "show[Decrypt and print a password]" \
- "insert[Insert a new password]" \
- "generate[Generate a new password using pwgen]" \
- "edit[Edit a password with \$EDITOR]" \
- "rm[Remove the password]" \
- "git[Call git on the password store]" \
- "help[Help]"
- _pass_cmd_show
- fi
-}
-
-_pass_cmd_init () {
-}
-_pass_cmd_ls () {
- _arguments : \
- '::ls:_get_stored_pwd'
+_pass () {
+ local cmd
+ if (( CURRENT > 2)); then
+ cmd=${words[2]}
+ # Set the context for the subcommand.
+ curcontext="${curcontext%:*:*}:pass-$cmd"
+ # Narrow the range of words we are looking at to exclude `pass'
+ (( CURRENT-- ))
+ shift words
+ # Run the completion for the subcommand
+ case "${cmd}" in
+ init)
+ _arguments : \
+ "-r[re-encrypt existing passwords]" \
+ "--reencrypt[re-encrypt existing passwords]"
+ _pass_complete_keys
+ ;;
+ ls|list|edit)
+ _pass_complete_entries_with_subdirs
+ ;;
+ insert)
+ _arguments : \
+ "-n[no console output]" \
+ "--no-echo[no console output]" \
+ "-m[multiline]" \
+ "--multiline[multiline]"
+ _pass_complete_entries_with_subdirs
+ ;;
+ generate)
+ _arguments : \
+ "-n[don't include symbols in password]" \
+ "--no-symbols[don't include symbols in password]" \
+ "-c[copy password to the clipboard]" \
+ "--clip[copy password to the clipboard]"
+ _pass_complete_entries_with_subdirs
+ ;;
+ rm)
+ _arguments : \
+ "-f[force deletion]" \
+ "--force[force deletion]" \
+ "-r[recursively delete]" \
+ "--recursive[recursively delete]"
+ _pass_complete_entries_with_subdirs
+ ;;
+ git)
+ _values 'subcommands' \
+ "init[Initialize git repository]" \
+ "push[Push to remote repository]" \
+ "pull[Pull from remote repository]" \
+ "config[Show git config]" \
+ "log[Show git log]" \
+ "reflog[Show git reflog]"
+ ;;
+ show|*)
+ _pass_cmd_show
+ ;;
+ esac
+ else
+ _values 'command' \
+ "init[Initialize new password storage]" \
+ "ls[List passwords]" \
+ "show[Decrypt and print a password]" \
+ "insert[Insert a new password]" \
+ "generate[Generate a new password using pwgen]" \
+ "edit[Edit a password with \$EDITOR]" \
+ "rm[Remove the password]" \
+ "git[Call git on the password store]" \
+ "version[Output version information]" \
+ "help[Output help message]"
+ _arguments : \
+ "--version[Output version information]" \
+ "--help[Output help message]"
+ _pass_cmd_show
+ fi
}
_pass_cmd_show () {
- _arguments : \
- "-c[put it on the clipboard]" \
- '*::show:_get_stored_pwd'
- #'::pass id:_files -W ~/.password-store -g "*.gpg(|.*)(-.)"'
+ _arguments : \
+ "-c[put it on the clipboard]" \
+ "--clip[put it on the clipboard]"
+ _pass_complete_entries
}
-
-_pass_cmd_edit () {
- _arguments : \
- '::edit:_get_stored_pwd'
+_pass_complete_entries_helper () {
+ local IFS=$'\n'
+ local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
+ _values -C 'passwords' $(find "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print | sed -e "s#${prefix}.##" -e 's#\.gpg##' | sort)
}
-_pass_cmd_insert () {
- _arguments : \
- "-n[no console output]" \
- "-m[multiline]" \
- '::show:_get_stored_pwd'
+_pass_complete_entries_with_subdirs () {
+ _pass_complete_entries_helper
}
-_pass_cmd_generate () {
- _arguments : \
- "-n[no symbols]" \
- "-c[put password on the clipboard]" \
- '::show:_get_stored_pwd'
+_pass_complete_entries () {
+ _pass_complete_entries_helper -type f
}
-_pass_cmd_rm () {
- _arguments : \
- '::ls:_get_stored_pwd'
-}
-
-_get_stored_pwd () {
- compadd `find ~/.password-store \( -name .git -o -name .gpg-id \) -prune -o -type f -print | sed 's#.*\.password-store*.##'| sed 's#\.gpg##' | sort`
-
+_pass_complete_keys () {
+ local IFS=$'\n'
+ # Extract names and email addresses from gpg --list-keys
+ _values 'gpg keys' $(gpg --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')
}
t'>Abstract remove empty directories into function.Jason A. Donenfeld1-14/+11 2014-04-18Remember to prune empty folders.Jason A. Donenfeld1-0/+8 2014-04-18init: allow deinitializationJason A. Donenfeld2-2/+18 2014-04-18bash-completion: filter dot files from resultsJason A. Donenfeld1-3/+8 2014-04-18reencrypt: remove option, do automaticallyJason A. Donenfeld5-39/+25 2014-04-18reencryption: add to completion filesJason A. Donenfeld3-1/+5 2014-04-18Specify variable gpg.Jason A. Donenfeld1-1/+1 2014-04-18style: don't escape new line on &&Jason A. Donenfeld1-2/+2 2014-04-18reencryption: remove temporary file on failureJason A. Donenfeld1-1/+1 2014-04-18reencryption: only reencrypt files when requiredJason A. Donenfeld2-16/+37 2014-04-17cp: typo as cvJason A. Donenfeld1-1/+1 2014-04-17bash: gpg_id is localJason A. Donenfeld1-0/+1 2014-04-17move/copy: always reencrypt passwords at destinationJason A. Donenfeld5-25/+56 2014-04-17makefile: allow platform files with gnu sedJason A. Donenfeld1-7/+8 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-04-17mv: Add pass mv/rename supportJason A. Donenfeld5-3/+78 Based-on-work-by: Matthieu Weber <mweber@free.fr> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-04-17revelation2pass: add plain XML importJavali1-11/+15 I found that revelatio2pass.py script doesn't work. It can not decrypt my password file. I got following error message: raceback (most recent call last): File "git/password-store/contrib/importers/revelation2pass.py", line 159, in <module> main(args.FILE, verbose=args.verbose, xml=args.xml) File "git/password-store/contrib/importers/revelation2pass.py", line 140, in main cleardata_gz = decrypt_gz(password, data) File "git/password-store/contrib/importers/revelation2pass.py", line 117, in decrypt_gz ct = c.decrypt(cipher_text[28:]) File "/usr/lib/python2.7/site-packages/Crypto/Cipher/blockalgo.py", line 295, in decrypt return self._cipher.decrypt(ciphertext) I was unable to fix the problem, but I created a workaround, that add plain XML import option to the revelation2pass.py script. Revelation can export its password file as plain XML format. 2014-04-17platform: add cygwin supportJason A. Donenfeld2-1/+17 According to Brandon Jones, all we need to do is adjust /dev/clipboard from xclip. So we add a platform specific file to do so. http://www.relaytheurgency.com/2014/04/pass-in-cygwin-relatively-simple.html Suggested-by: Brandon Jones <jones.brandon.lee@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>