1#compdef gopass 2 3_gopass () { 4 local cmd 5 if (( CURRENT > 2)); then 6 cmd=${words[2]} 7 curcontext="${curcontext%:*:*}:gopass-$cmd" 8 (( CURRENT-- )) 9 shift words 10 case "${cmd}" in 11 alias) 12 local -a subcommands 13 subcommands=( 14 "add:Add a new alias" 15 "remove:Remove an alias from a domain" 16 "delete:Delete an entire domain" 17 ) 18 19 _describe -t commands "gopass alias" subcommands 20 21 22 ;; 23 audit) 24 25 _describe -t commands "gopass audit" subcommands 26 27 28 ;; 29 cat) 30 31 _describe -t commands "gopass cat" subcommands 32 33 34 ;; 35 clone) 36 _arguments : "--path[Path to clone the repo to]" "--crypto[Select crypto backend [age gpgcli plain]]" 37 _describe -t commands "gopass clone" subcommands 38 39 40 ;; 41 completion) 42 local -a subcommands 43 subcommands=( 44 "bash:Source for auto completion in bash" 45 "zsh:Source for auto completion in zsh" 46 "fish:Source for auto completion in fish" 47 "openbsdksh:Source for auto completion in OpenBSD's ksh" 48 ) 49 50 _describe -t commands "gopass completion" subcommands 51 52 53 ;; 54 config) 55 56 _describe -t commands "gopass config" subcommands 57 58 59 ;; 60 convert) 61 _arguments : "--store[Specify which store to convert]" "--move[Replace store?]" "--crypto[Which crypto backend? [age gpgcli plain]]" "--storage[Which storage backend? [fs gitfs]]" 62 _describe -t commands "gopass convert" subcommands 63 64 65 ;; 66 copy|cp) 67 _arguments : "--force[Force to copy the secret and overwrite existing one]" 68 _describe -t commands "gopass copy" subcommands 69 70 _gopass_complete_passwords 71 ;; 72 create|new) 73 _arguments : "--store[Which store to use]" "--force[Force path selection]" 74 _describe -t commands "gopass create" subcommands 75 76 77 ;; 78 delete|remove|rm) 79 _arguments : "--recursive[Recursive delete files and folders]" "--force[Force to delete the secret]" 80 _describe -t commands "gopass delete" subcommands 81 82 _gopass_complete_passwords 83 ;; 84 edit|set) 85 _arguments : "--editor[Use this editor binary]" "--create[Create a new secret if none found]" 86 _describe -t commands "gopass edit" subcommands 87 88 _gopass_complete_passwords 89 ;; 90 env) 91 92 _describe -t commands "gopass env" subcommands 93 94 95 ;; 96 find|search) 97 _arguments : "--clip[Copy the password into the clipboard]" "--unsafe[In the case of an exact match, display the password even if safecontent is enabled]" 98 _describe -t commands "gopass find" subcommands 99 100 101 ;; 102 fsck) 103 _arguments : "--decrypt[Decrypt and reencryt during fsck. 104WARNING: This will update the secret content to the latest format. This might be incompatible with other implementations. Use with caution!]" 105 _describe -t commands "gopass fsck" subcommands 106 107 108 ;; 109 fscopy) 110 111 _describe -t commands "gopass fscopy" subcommands 112 113 114 ;; 115 fsmove) 116 117 _describe -t commands "gopass fsmove" subcommands 118 119 120 ;; 121 generate) 122 _arguments : "--clip[Copy the generated password to the clipboard]" "--print[Print the generated password to the terminal]" "--force[Force to overwrite existing password]" "--edit[Open secret for editing after generating a password]" "--symbols[Use symbols in the password]" "--generator[Choose a password generator, use one of: cryptic, memorable, xkcd or external. Default: cryptic]" "--strict[Require strict character class rules]" "--sep[Word separator for generated passwords. If no separator is specified, the words are combined without spaces/separator and the first character of words is capitalised.]" "--lang[Language to generate password from, currently de (german) and en (english, default) are supported]" 123 _describe -t commands "gopass generate" subcommands 124 _gopass_complete_folders 125 _gopass_complete_passwords 126 ;; 127 git) 128 local -a subcommands 129 subcommands=( 130 "init:Init git repo" 131 "remote:Manage git remotes" 132 "push:Push to remote" 133 "pull:Pull from remote" 134 "status:RCS status" 135 ) 136 137 _describe -t commands "gopass git" subcommands 138 139 140 ;; 141 grep) 142 _arguments : "--regexp[Interpret pattern as RE2 regular expression]" 143 _describe -t commands "gopass grep" subcommands 144 145 146 ;; 147 history|hist) 148 _arguments : "--password[Include passwords in output]" 149 _describe -t commands "gopass history" subcommands 150 151 152 ;; 153 init) 154 _arguments : "--path[Set the sub-store path to operate on]" "--store[Set the name of the sub-store]" "--crypto[Select crypto backend [age gpgcli plain]]" "--storage[Select storage backend [fs gitfs]]" 155 _describe -t commands "gopass init" subcommands 156 157 158 ;; 159 insert) 160 _arguments : "--echo[Display secret while typing]" "--multiline[Insert using $EDITOR]" "--force[Overwrite any existing secret and do not prompt to confirm recipients]" "--append[Append data read from STDIN to existing data]" 161 _describe -t commands "gopass insert" subcommands 162 _gopass_complete_folders 163 _gopass_complete_passwords 164 ;; 165 link|ln|symlink) 166 167 _describe -t commands "gopass link" subcommands 168 169 170 ;; 171 list|ls) 172 _arguments : "--limit[Display no more than this many levels of the tree]" "--flat[Print a flat list]" "--folders[Print a flat list of folders]" "--strip-prefix[Strip this prefix from filtered entries]" 173 _describe -t commands "gopass list" subcommands 174 _gopass_complete_folders 175 176 ;; 177 merge) 178 _arguments : "--delete[Remove merged entries]" "--force[Skip editor, merge entries unattended]" 179 _describe -t commands "gopass merge" subcommands 180 181 182 ;; 183 mounts) 184 local -a subcommands 185 subcommands=( 186 "add:Mount a password store" 187 "remove:Umount an mounted password store" 188 ) 189 190 _describe -t commands "gopass mounts" subcommands 191 192 193 ;; 194 move|mv) 195 _arguments : "--force[Force to move the secret and overwrite existing one]" 196 _describe -t commands "gopass move" subcommands 197 198 _gopass_complete_passwords 199 ;; 200 otp|totp|hotp) 201 _arguments : "--clip[Copy the time-based token into the clipboard]" "--qr[Write QR code to FILE]" "--password[Only display the token]" 202 _describe -t commands "gopass otp" subcommands 203 204 205 ;; 206 pwgen) 207 _arguments : "--no-numerals[Do not include numerals in the generated passwords.]" "--no-capitalize[Do not include capital letter in the generated passwords.]" "--ambiguous[Do not include characters that could be easily confused with each other, like '1' and 'l' or '0' and 'O']" "--symbols[Include at least one symbol in the password.]" "--one-per-line[Print one password per line]" "--xkcd[Use multiple random english words combined to a password. By default, space is used as separator and all words are lowercase]" "--sep[Word separator for generated xkcd style password. If no separator is specified, the words are combined without spaces/separator and the first character of words is capitalised. This flag implies -xkcd]" "--lang[Language to generate password from, currently de (german) and en (english, default) are supported]" 208 _describe -t commands "gopass pwgen" subcommands 209 210 211 ;; 212 recipients) 213 local -a subcommands 214 subcommands=( 215 "add:Add any number of Recipients to any store" 216 "remove:Remove any number of Recipients from any store" 217 ) 218 219 _describe -t commands "gopass recipients" subcommands 220 221 222 ;; 223 setup) 224 _arguments : "--remote[URL to a git remote, will attempt to join this team]" "--alias[Local mount point for the given remote]" "--create[Create a new team (default: false, i.e. join an existing team)]" "--name[Firstname and Lastname for unattended GPG key generation]" "--email[EMail for unattended GPG key generation]" "--crypto[Select crypto backend [age gpgcli plain]]" "--storage[Select storage backend [fs gitfs]]" 225 _describe -t commands "gopass setup" subcommands 226 227 228 ;; 229 show) 230 _arguments : "--yes[Always answer yes to yes/no questions]" "--clip[Copy the password value into the clipboard]" "--alsoclip[Copy the password and show everything]" "--qr[Print the password as a QR Code]" "--unsafe[Display unsafe content (e.g. the password) even if safecontent is enabled]" "--password[Display only the password. Takes precedence over all other flags.]" "--revision[Show a past revision. Does NOT support RCS specific shortcuts. Use exact revision or -N to select the Nth oldest revision of this entry.]" "--noparsing[Do not parse the output.]" 231 _describe -t commands "gopass show" subcommands 232 233 _gopass_complete_passwords 234 ;; 235 sum|sha|sha256) 236 237 _describe -t commands "gopass sum" subcommands 238 239 240 ;; 241 sync) 242 _arguments : "--store[Select the store to sync]" 243 _describe -t commands "gopass sync" subcommands 244 245 246 ;; 247 templates) 248 local -a subcommands 249 subcommands=( 250 "show:Show a secret template." 251 "edit:Edit secret templates." 252 "remove:Remove secret templates." 253 ) 254 255 _describe -t commands "gopass templates" subcommands 256 257 258 ;; 259 unclip) 260 _arguments : "--timeout[Time to wait]" "--force[Clear clipboard even if checksum mismatches]" 261 _describe -t commands "gopass unclip" subcommands 262 263 264 ;; 265 update) 266 267 _describe -t commands "gopass update" subcommands 268 269 270 ;; 271 version) 272 273 _describe -t commands "gopass version" subcommands 274 275 276 ;; 277 help|h) 278 279 _describe -t commands "gopass help" subcommands 280 281 282 ;; 283 *) 284 _gopass_complete_passwords 285 ;; 286 esac 287 else 288 local -a subcommands 289 subcommands=( 290 "alias:Manage domain aliases" 291 "audit:Decrypt all secrets and scan for weak or leaked passwords" 292 "cat:Print content of a secret to stdout, or insert from stdin" 293 "clone:Clone a password store from a git repository" 294 "completion:Bash and ZSH completion" 295 "config:Display and edit the configuration file" 296 "convert:Convert a store to different backends" 297 "copy:Copy secrets from one location to another" 298 "create:Easy creation of new secrets" 299 "delete:Remove one or many secrets from the store" 300 "edit:Edit new or existing secrets" 301 "env:Run a subprocess with a pre-populated environment" 302 "find:Search for secrets" 303 "fsck:Check store integrity" 304 "fscopy:Copy files from or to the password store" 305 "fsmove:Move files from or to the password store" 306 "generate:Generate a new password" 307 "git:Run a git command inside a password store (init, remote, push, pull)" 308 "grep:Search for secrets files containing search-string when decrypted." 309 "history:Show password history" 310 "init:Initialize new password store." 311 "insert:Insert a new secret" 312 "link:Create a symlink" 313 "list:List existing secrets" 314 "merge:Merge multiple secrets into one" 315 "mounts:Edit mounted stores" 316 "move:Move secrets from one location to another" 317 "otp:Generate time- or hmac-based tokens" 318 "pwgen:Generate passwords" 319 "recipients:Edit recipient permissions" 320 "setup:Initialize a new password store" 321 "show:Display the content of a secret" 322 "sum:Compute the SHA256 checksum" 323 "sync:Sync all local stores with their remotes" 324 "templates:Edit templates" 325 "unclip:Internal command to clear clipboard" 326 "update:Check for updates" 327 "version:Display version" 328 "help:Shows a list of commands or help for one command" 329 ) 330 _describe -t command 'gopass' subcommands 331 _arguments : "--yes[Always answer yes to yes/no questions]" "--clip[Copy the password value into the clipboard]" "--alsoclip[Copy the password and show everything]" "--qr[Print the password as a QR Code]" "--unsafe[Display unsafe content (e.g. the password) even if safecontent is enabled]" "--password[Display only the password. Takes precedence over all other flags.]" "--revision[Show a past revision. Does NOT support RCS specific shortcuts. Use exact revision or -N to select the Nth oldest revision of this entry.]" "--noparsing[Do not parse the output.]" "--help[show help]" "--version[print the version]" 332 _gopass_complete_passwords 333 fi 334} 335 336_gopass_complete_keys () { 337 local IFS=$'\n' 338 _values 'gpg keys' $(gpg2 --list-secret-keys --with-colons 2> /dev/null | cut -d : -f 10 | sort -u | sed '/^$/d') 339} 340 341_gopass_complete_passwords () { 342 local IFS=$'\n' 343 _arguments : \ 344 "--clip[Copy the first line of the secret into the clipboard]" 345 _values 'passwords' $(gopass ls --flat) 346} 347 348_gopass_complete_folders () { 349 local -a folders 350 folders=("${(@f)$(gopass ls --folders --flat)}") 351 _describe -t folders "folders" folders -qS / 352} 353 354_gopass 355