~ubuntu-branches/debian/jessie/password-store/jessie

« back to all changes in this revision

Viewing changes to .pc/gnupg1-support.patch/contrib/pass.zsh-completion

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-04-14 16:40:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140414164029-lfkwiep2sltmsaic
Tags: 1.5-1
* New upstream release (closes: #744723).
  - Fix typos in "pass generate" documentation (closes: #739949).
* Go back to recommending xclip; pass now supports asking it to copy to
  the PRIMARY selection using PASSWORD_STORE_X_SELECTION=primary.
* Use dh_python2 to stop python-support generating
  /usr/share/python-support/pass.private.

Show diffs side-by-side

added added

removed removed

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