From 33983a60bcf2cd8b68e762354fd6181cb00e3941 Mon Sep 17 00:00:00 2001 From: Sasha <24563334+aanpilov@users.noreply.github.com> Date: Wed, 23 May 2018 22:27:18 +0300 Subject: [PATCH] Update autocomplete to use built in function Use autocomplete rules from binary instead of plain shell script. This way it is more future proof, no need to update plugin with every `gopass` release. --- plugins/gopass/_gopass | 268 +---------------------------------------- 1 file changed, 3 insertions(+), 265 deletions(-) diff --git a/plugins/gopass/_gopass b/plugins/gopass/_gopass index 93f298b3d..c8c8fb6b6 100644 --- a/plugins/gopass/_gopass +++ b/plugins/gopass/_gopass @@ -1,268 +1,6 @@ -#compdef gopass -# The slightly more awesome standard unix password manager -# for teams +# The slightly more awesome standard unix password manager for teams +# # https://www.justwatch.com/gopass # https://github.com/justwatchcom/gopass -_gopass () { - local cmd - if (( CURRENT > 2)); then - cmd=${words[2]} - curcontext="${curcontext%:*:*}:gopass-$cmd" - (( CURRENT-- )) - shift words - case "${cmd}" in - agent) - local -a subcommands - subcommands=( - "client:Start a simple agent test client" - ) - - _describe -t commands "gopass agent" subcommands - ;; - audit) - local -a subcommands - subcommands=( - "hibp:Detect leaked passwords" - ) - _arguments : "--jobs[The number of jobs to run concurrently when auditing]" - _describe -t commands "gopass audit" subcommands - ;; - binary|bin) - local -a subcommands - subcommands=( - "cat:Print content of a secret to stdout or insert from stdin" - "sum:Compute the SHA256 checksum" - "copy:Copy files from or to the password store" - "move:Move files from or to the password store" - ) - - _describe -t commands "gopass binary" subcommands - ;; - clone) - _arguments : "--path[Path to clone the repo to]" "--crypto[Select crypto backend (gpg, gpgcli, plain, xc)]" "--sync[Select sync backend (git, gitcli, gogit, noop)]" - _describe -t commands "gopass clone" subcommands - ;; - completion) - local -a subcommands - subcommands=( - "bash:Source for auto completion in bash" - "zsh:Source for auto completion in zsh" - "fish:Source for auto completion in fish" - "openbsdksh:Source for auto completion in OpenBSD's ksh" - ) - - _describe -t commands "gopass completion" subcommands - ;; - config) - _arguments : "--store[Set value to substore config]" - _describe -t commands "gopass config" subcommands - ;; - copy|cp) - _arguments : "--force[Force to copy the secret and overwrite existing one]" - _describe -t commands "gopass copy" subcommands - _gopass_complete_passwords;; - create|new) - - _describe -t commands "gopass create" subcommands - ;; - delete|remove|rm) - _arguments : "--recursive[f]" "--force[Force to delete the secret]" - _describe -t commands "gopass delete" subcommands - _gopass_complete_passwords;; - edit|set) - _arguments : "--editor[Use this editor binary]" - _describe -t commands "gopass edit" subcommands - _gopass_complete_passwords;; - find|search) - _arguments : "--clip[Copy the password into the clipboard]" - _describe -t commands "gopass find" subcommands - ;; - fsck) - - _describe -t commands "gopass fsck" subcommands - ;; - generate) - _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]" "--xkcd[Use multiple random english words combined to a password. If no separator is specified, the words are combined without spaces/separator and the first character of words is capitalised]" "--xkcdsep[Word separator for generated xkcd style password. Implies -xkcd]" "--xkcdlang[Language to generate password from, currently de (german) and en (english, default) are supported]" - _describe -t commands "gopass generate" subcommands - ;; - jsonapi) - local -a subcommands - subcommands=( - "listen:Listen and respond to messages via stdin/stdout" - "configure:Setup gopass native messaging manifest for selected browser" - ) - - _describe -t commands "gopass jsonapi" subcommands - ;; - otp|totp|hotp) - _arguments : "--clip[Copy the time based token into the clipboard]" "--qr[Write QR code to `FILE`]" - _describe -t commands "gopass otp" subcommands - ;; - git) - local -a subcommands - subcommands=( - "init:Init git repo" - "remote:Mangage git remotes" - "push:Push to remote" - "pull:Pull from remote" - ) - - _describe -t commands "gopass git" subcommands - ;; - grep) - - _describe -t commands "gopass grep" subcommands - ;; - history|hist) - _arguments : "--password[Include passwords in output]" - _describe -t commands "gopass history" subcommands - ;; - init) - _arguments : "--path[Set the sub store path to operate on]" "--store[Set the name of the sub store]" "--crypto[Select crypto backend (gpg, gpgcli, plain, xc)]" "--rcs[Select sync backend (git, gitcli, gogit, noop)]" - _describe -t commands "gopass init" subcommands - ;; - insert) - _arguments : "--echo[Display secret while typing]" "--multiline[Insert using $EDITOR]" "--force[Overwrite any existing secret and do not prompt to confirm recipients]" - _describe -t commands "gopass insert" subcommands - ;; - list|ls) - _arguments : "--limit[Max tree depth]" "--flat[Print flat list]" "--strip-prefix[Strip prefix from filtered entries]" - _describe -t commands "gopass list" subcommands - ;; - move|mv) - _arguments : "--force[Force to move the secret and overwrite existing one]" - _describe -t commands "gopass move" subcommands - _gopass_complete_passwords;; - mounts) - local -a subcommands - subcommands=( - "add:Mount a password store" - "remove:Umount an mounted password store" - ) - - _describe -t commands "gopass mounts" subcommands - ;; - recipients) - local -a subcommands - subcommands=( - "add:Add any number of Recipients to any store" - "remove:Remove any number of Recipients from any store" - ) - - _describe -t commands "gopass recipients" subcommands - ;; - setup) - _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 (gpg, gpgcli, plain, xc)]" "--rcs[Select sync backend (git, gitcli, gogit, noop)]" - _describe -t commands "gopass setup" subcommands - ;; - show) - _arguments : "--clip[Copy the first line of the secret into the clipboard]" "--qr[Print the first line of the secret as QR Code]" "--force[Display the password even if safecontent is enabled]" "--password[Display only the password]" "--sync[Sync before attempting to display the secret]" "--revision[Show a past revision]" - _describe -t commands "gopass show" subcommands - _gopass_complete_passwords;; - sync) - _arguments : "--store[Select the store to sync]" - _describe -t commands "gopass sync" subcommands - ;; - templates) - local -a subcommands - subcommands=( - "show:Show a secret template." - "edit:Edit secret templates." - "remove:Remove secret templates." - ) - - _describe -t commands "gopass templates" subcommands - ;; - unclip) - _arguments : "--timeout[Time to wait]" "--force[Clear clipboard even if checksum mismatches]" - _describe -t commands "gopass unclip" subcommands - ;; - update) - _arguments : "--pre[Update to prereleases]" - _describe -t commands "gopass update" subcommands - ;; - version) - - _describe -t commands "gopass version" subcommands - ;; - xc) - local -a subcommands - subcommands=( - "list-private-keys:" - "list-public-keys:" - "generate:" - "export:" - "import:" - "export-private-key:" - "import-private-key:" - "remove:" - "encrypt:" - "decrypt:" - ) - - _describe -t commands "gopass xc" subcommands - ;; - help|h) - - _describe -t commands "gopass help" subcommands - ;; - *) - _gopass_complete_passwords - ;; - esac - else - local -a subcommands - subcommands=( - "agent:Start gopass-agent" - "audit:Scan for weak passwords" - "binary:Assist with Binary/Base64 content" - "clone:Clone a store from git" - "completion:Bash and ZSH completion" - "config:Edit configuration" - "copy:Copy secrets from one location to another" - "create:Easy creation of new secrets" - "delete:Remove secrets" - "edit:Edit new or existing secret" - "find:Search for secrets" - "fsck:Check store integrity" - "generate:Generate a new password" - "jsonapi:Run gopass as jsonapi e.g. for browser plugins" - "otp:Generate time or hmac based tokens" - "git:Run any git command inside a password store" - "grep:Search for secrets files containing search-string when decrypted." - "history:Show password history" - "init:Initialize new password store." - "insert:Insert a new secret" - "list:List existing secrets" - "move:Move secrets from one location to another" - "mounts:Edit mounted stores" - "recipients:Edit recipient permissions" - "setup:Initialize a new password store" - "show:Display a secret" - "sync:Sync all local stores with their remotes" - "templates:Edit templates" - "unclip:Internal command to clear clipboard" - "update:Check for updates" - "version:Display version" - "xc:Experimental Crypto" - "help:Shows a list of commands or help for one command" - ) - _describe -t command 'gopass' subcommands - _arguments : "--yes[Assume yes on all yes/no questions or use the default on all others]" "--clip[Copy the first line of the secret into the clipboard]" "--help[show help]" "--version[print the version]" - _gopass_complete_passwords - fi -} - -_gopass_complete_keys () { - local IFS=$'\n' - _values 'gpg keys' $(gpg2 --list-secret-keys --with-colons 2> /dev/null | cut -d : -f 10 | sort -u | sed '/^$/d') -} - -_gopass_complete_passwords () { - _arguments : \ - "--clip[Copy the first line of the secret into the clipboard]" - _values 'passwords' $(gopass ls --flat) -} - -_gopass +source <(gopass completion zsh)