summaryrefslogtreecommitdiff
path: root/contrib/pass.zsh-completion
blob: bfe5dcafcb9829dddf7ded3092e7e3155565a592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#compdef pass

# 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


_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_cmd_show () {
  _arguments : \
    "-c[put it on the clipboard]" \
    '*::show:_get_stored_pwd'
    #'::pass id:_files -W ~/.password-store -g "*.gpg(|.*)(-.)"'
}

_pass_cmd_edit () {
  _arguments : \
    '::edit:_get_stored_pwd'
}

_pass_cmd_insert () {
  _arguments : \
    "-n[no console output]" \
    "-m[multiline]" \
    '::show:_get_stored_pwd'
}

_pass_cmd_generate () {
  _arguments : \
    "-n[no symbols]" \
    "-c[put password on the clipboard]" \
    '::show:_get_stored_pwd'
}

_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`

}
portato.git/commit/portato/session.py?h=no_config&id=f9a4a36b341b1d866269f568e86cbf63b90b5f63&follow=1'> r609@Devoty: necoro | 2008-01-14 17:04:38 +0100Necoro9-394/+477 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108