tpm

Tiny password manager

git clone https://git.8pit.net/tpm.git

 1#compdef tpm
 2# Copyright (C) 2013-2015 Sören Tempel
 3#
 4# This program is free software: you can redistribute it and/or modify
 5# it under the terms of the GNU General Public License as published by
 6# the Free Software Foundation, either version 3 of the License, or
 7# (at your option) any later version.
 8#
 9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17_tpm() {
18  local cmd=${words[2]}
19
20  case "${cmd}" in
21    "insert")
22      _tpm_complete_entries
23      ;;
24    "show")
25      _tpm_complete_entries -type f
26      ;;
27    *)
28      local subcommands=(
29        "show:Show a password for a specified entry"
30        "insert:Insert a new password entry"
31      )
32
33      _describe -t commands "tpm" subcommands
34      ;;
35  esac
36}
37
38_tpm_complete_entries() {
39  local dir="${PASSWORD_STORE_DIR:-${HOME}/.password-store}"
40
41  if [[ -d "${dir}" ]]; then
42    _values -C "entries" \
43      $(find -L "${dir}/" -name ".git" -prune -o $@ -print | sed -e "s|${dir}.||" -e "s|\.gpg||" | sort)
44  fi
45}
46
47# vim: et:sw=2:sts=2