aad58afc54d65623f5e71bd8104e64bae6a98c96

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1386 from sanbor/master

Pass plugin for completion

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/pass/_pass b/plugins/pass/_pass
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..f6c1a6c4bd36ebe5fd6e347412e730578cc73000
  4--- /dev/null
  5+++ b/plugins/pass/_pass
  6@@ -0,0 +1,119 @@
  7+#compdef pass
  8+#autoload
  9+
 10+# Copyright (C) 2012:
 11+#    Johan Venant <jvenant@invicem.pro>
 12+#    Brian Mattern <rephorm@rephorm.com>
 13+#    Jason A. Donenfeld <Jason@zx2c4.com>.
 14+#    Santiago Borrazás <sanbor@gmail.com>
 15+# All Rights Reserved.
 16+# This file is licensed under the GPLv2+. Please see COPYING for more information.
 17+
 18+
 19+_pass () {
 20+	local cmd
 21+	if (( CURRENT > 2)); then
 22+		cmd=${words[2]}
 23+		# Set the context for the subcommand.
 24+		curcontext="${curcontext%:*:*}:pass-$cmd"
 25+		# Narrow the range of words we are looking at to exclude `pass'
 26+		(( CURRENT-- ))
 27+		shift words
 28+		# Run the completion for the subcommand
 29+		case "${cmd}" in
 30+			init)
 31+				_arguments : \
 32+					"-r[re-encrypt existing passwords]" \
 33+					"--reencrypt[re-encrypt existing passwords]"
 34+				_pass_complete_keys
 35+				;;
 36+			ls|list|edit)
 37+				_pass_complete_entries_with_subdirs
 38+				;;
 39+			insert)
 40+				_arguments : \
 41+					"-e[echo password to console]" \
 42+					"--echo[echo password to console]" \
 43+					"-m[multiline]" \
 44+					"--multiline[multiline]"
 45+				_pass_complete_entries_with_subdirs
 46+				;;
 47+			generate)
 48+				_arguments : \
 49+					"-n[don't include symbols in password]" \
 50+					"--no-symbols[don't include symbols in password]" \
 51+					"-c[copy password to the clipboard]" \
 52+					"--clip[copy password to the clipboard]"
 53+				_pass_complete_entries_with_subdirs
 54+				;;
 55+			rm)
 56+				_arguments : \
 57+					"-f[force deletion]" \
 58+					"--force[force deletion]" \
 59+					"-r[recursively delete]" \
 60+					"--recursive[recursively delete]"
 61+					_pass_complete_entries_with_subdirs
 62+				;;
 63+			git)
 64+				local -a subcommands
 65+				subcommands=(
 66+					"init:Initialize git repository"
 67+					"push:Push to remote repository"
 68+					"pull:Pull from remote repository"
 69+					"config:Show git config"
 70+					"log:Show git log"
 71+					"reflog:Show git reflog"
 72+				)
 73+				_describe -t commands 'pass git' subcommands
 74+				;;
 75+			show|*)
 76+				_pass_cmd_show
 77+				;;
 78+		esac
 79+	else
 80+		local -a subcommands
 81+		subcommands=(
 82+			"init:Initialize new password storage"
 83+			"ls:List passwords"
 84+			"show:Decrypt and print a password"
 85+			"insert:Insert a new password"
 86+			"generate:Generate a new password using pwgen"
 87+			"edit:Edit a password with \$EDITOR"
 88+			"rm:Remove the password"
 89+			"git:Call git on the password store"
 90+			"version:Output version information"
 91+			"help:Output help message"
 92+		)
 93+		_describe -t commands 'pass' subcommands
 94+		_arguments : \
 95+			"--version[Output version information]" \
 96+			"--help[Output help message]"
 97+		_pass_cmd_show
 98+	fi
 99+}
100+
101+_pass_cmd_show () {
102+	_arguments : \
103+		"-c[put it on the clipboard]" \
104+		"--clip[put it on the clipboard]"
105+	_pass_complete_entries