4 local cmd has_color has_sync has_interactive
5 if (( CURRENT > 2)); then
7 # Set the context for the subcommand.
8 curcontext="${curcontext%:*:*}:lpass-$cmd"
9 # Narrow the range of words we are looking at to exclude `lpass'
12 # Run the completion for the subcommand
16 '--trust[Cause subsequent logins to not require multifactor authentication.]' \
17 '--plaintext-key[Save plaintext decryption key to the hard disk]' \
18 '--force[Do not ask on saving plaintext key]'
23 _arguments : '--force[Force confirmation]'
28 '(-c --clip)'{-c,--clip}'[Copy output to clipboard]' \
29 '(-x --expand-multi)'{-x,---expand-multi}'[Show the requested information from all of the matching sites]' \
30 '(--all --username --password --url --notes --field= --id --name --attach=)'{--all,--username,--password,--url,--notes,--field=,--id,--name,--attach=}'[Output the specific field]' \
31 '(--basic-regexp,--fixed-string)'{-G,--basic-regexp}'[Find a site by substring or regular expression]' \
32 '--format=[Format output with printf-style placeholders]'
33 _lpass_complete_uniqenames
40 '(-l --long)'{-l,--long}'[Also list the last modification time and username]' \
42 '-m[List modification time]' \
43 '--format=[Format output with printf-style placeholders]'
44 _lpass_complete_groups
49 _lpass_complete_uniqenames
50 _lpass_complete_groups
54 _lpass_complete_uniqenames
59 _arguments : '(--username --password --url --notes --field=)'{--username,--password,--url,--notes,--field=}'[Add field]'
60 _lpass_complete_uniqenames
66 _arguments : '(--name --username --password --url --notes --field=)'{--name,--username,--password,--url,--notes,--field=}'[Update field]'
67 _lpass_complete_uniqenames
74 '(-c --clip)'{-c,--clip}'[Copy output to clipboard]' \
75 '--username=[USERNAME]' \
77 '--no-symbols[Do not use symbols]'
81 _arguments : '(-q --quiet)'{-q,--quiet}'[Supress output to stdout]'
85 _arguments : '(-b --background)'{-b,--background}'[Run sync in background]'
89 _arguments : '--fields=[Field list]'
94 if ((CURRENT < 3)); then
100 if [ -n "$has_sync" ] || [ -n "$has_color" ] || [ -n "$has_interactive" ]; then
101 local -a generic_options
102 if [ "$has_sync" -eq 1 ]; then
103 generic_options+=('--sync=[Synchronize local cache with server: auto | now | no]')
105 if [ "$has_color" -eq 1 ]; then
106 generic_options+=('--color=[Color: auto | never | always]')
108 if [ "$has_interactive" -eq 1 ]; then
109 generic_options+=("--non-interactive[Use standard input instead of $EDITOR]")
111 _arguments $generic_options
116 "login:Authenticate with the LastPass server and initialize a local cache"
117 "logout:Remove the local cache and stored encryption keys"
118 "passwd:Change your LastPass password"
119 "show:Display a password or selected field"
120 "ls:List names in groups in a tree structure"
121 "mv:Move the specified entry to a new group"
122 "add:Add a new entry"
123 "edit:Edit the selected field"
124 "generate:Create a randomly generated password"
125 "duplicate:Create a duplicate entry of the one specified"
126 "rm:Remove the specified entry"
127 "status:Show current login status"
128 "sync:Synchronize local cache with server"
129 "export:Dump all account information including passwords as unencrypted csv to stdout"
130 "import:Upload accounts from an unencrypted CSV file to the server"
131 "share:Manipulate shared folders (only enterprise or premium user)"
133 _describe -t commands 'lpass' subcommands
135 '(-h --help)'{-h,--help}'[show help]' \
136 '(-v --version)'{-v,--version}'[show version]'
141 _lpass_complete_uniqenames(){
147 done < <(lpass ls --sync auto --format "%an" --color=never)
152 _lpass_complete_groups() {
158 done < <(lpass ls --sync auto --format "%aN" --color=never | grep -E "\/$")
166 # indent-tabs-mode: nil
169 # vim: ft=zsh sw=2 ts=2 et