my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
3.9 KiB

3 years ago
  1. #compdef pass
  2. #autoload
  3. # Copyright (C) 2012 - 2014:
  4. # Johan Venant <[email protected]>
  5. # Brian Mattern <[email protected]>
  6. # Jason A. Donenfeld <[email protected]>.
  7. # All Rights Reserved.
  8. # This file is licensed under the GPLv2+. Please see COPYING for more information.
  9. # If you use multiple repositories, you can configure completion like this:
  10. #
  11. # compdef _pass workpass
  12. # zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
  13. # workpass() {
  14. # PASSWORD_STORE_DIR=$HOME/work/pass pass $@
  15. # }
  16. _pass () {
  17. local cmd
  18. if (( CURRENT > 2)); then
  19. cmd=${words[2]}
  20. # Set the context for the subcommand.
  21. curcontext="${curcontext%:*:*}:pass-$cmd"
  22. # Narrow the range of words we are looking at to exclude `pass'
  23. (( CURRENT-- ))
  24. shift words
  25. # Run the completion for the subcommand
  26. case "${cmd}" in
  27. init)
  28. _arguments : \
  29. "-p[gpg-id will only be applied to this subfolder]" \
  30. "--path[gpg-id will only be applied to this subfolder]"
  31. _pass_complete_keys
  32. ;;
  33. ls|list|edit)
  34. _pass_complete_entries_with_subdirs
  35. ;;
  36. insert)
  37. _arguments : \
  38. "-e[echo password to console]" \
  39. "--echo[echo password to console]" \
  40. "-m[multiline]" \
  41. "--multiline[multiline]"
  42. _pass_complete_entries_with_subdirs
  43. ;;
  44. generate)
  45. _arguments : \
  46. "-n[don't include symbols in password]" \
  47. "--no-symbols[don't include symbols in password]" \
  48. "-c[copy password to the clipboard]" \
  49. "--clip[copy password to the clipboard]" \
  50. "-f[force overwrite]" \
  51. "--force[force overwrite]" \
  52. "-i[replace first line]" \
  53. "--in-place[replace first line]"
  54. _pass_complete_entries_with_subdirs
  55. ;;
  56. cp|copy|mv|rename)
  57. _arguments : \
  58. "-f[force rename]" \
  59. "--force[force rename]"
  60. _pass_complete_entries_with_subdirs
  61. ;;
  62. rm)
  63. _arguments : \
  64. "-f[force deletion]" \
  65. "--force[force deletion]" \
  66. "-r[recursively delete]" \
  67. "--recursive[recursively delete]"
  68. _pass_complete_entries_with_subdirs
  69. ;;
  70. git)
  71. local -a subcommands
  72. subcommands=(
  73. "init:Initialize git repository"
  74. "push:Push to remote repository"
  75. "pull:Pull from remote repository"
  76. "config:Show git config"
  77. "log:Show git log"
  78. "reflog:Show git reflog"
  79. )
  80. _describe -t commands 'pass git' subcommands
  81. ;;
  82. show|*)
  83. _pass_cmd_show
  84. ;;
  85. esac
  86. else
  87. local -a subcommands
  88. subcommands=(
  89. "init:Initialize new password storage"
  90. "ls:List passwords"
  91. "find:Find password files or directories based on pattern"
  92. "grep:Search inside decrypted password files for matching pattern"
  93. "show:Decrypt and print a password"
  94. "insert:Insert a new password"
  95. "generate:Generate a new password using pwgen"
  96. "edit:Edit a password with \$EDITOR"
  97. "mv:Rename the password"
  98. "cp:Copy the password"
  99. "rm:Remove the password"
  100. "git:Call git on the password store"
  101. "version:Output version information"
  102. "help:Output help message"
  103. )
  104. _describe -t commands 'pass' subcommands
  105. _arguments : \
  106. "--version[Output version information]" \
  107. "--help[Output help message]"
  108. _pass_cmd_show
  109. fi
  110. }
  111. _pass_cmd_show () {
  112. _arguments : \
  113. "-c[put it on the clipboard]" \
  114. "--clip[put it on the clipboard]"
  115. _pass_complete_entries
  116. }
  117. _pass_complete_entries_helper () {
  118. local IFS=$'\n'
  119. local prefix
  120. zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
  121. _values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#g' -e 's#:#\\:#g' | sort):-""}
  122. }
  123. _pass_complete_entries_with_subdirs () {
  124. _pass_complete_entries_helper
  125. }
  126. _pass_complete_entries () {
  127. _pass_complete_entries_helper -type f
  128. }
  129. _pass_complete_keys () {
  130. local IFS=$'\n'
  131. # Extract names and email addresses from gpg --list-keys
  132. _values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')
  133. }
  134. _pass