-
Notifications
You must be signed in to change notification settings - Fork 6
/
_contact
40 lines (37 loc) · 1.08 KB
/
_contact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#compdef contact
_contact_commands() {
local -a contact_ary
contact_ary=(
'add':'add a new contact'
'edit':'edit an existing contact'
'delete':'delete a contact'
'getfiltered':'start interactive prompt, but only list properties matching $2'
'get':'issue a query'
'git':'run a git command in the contacts directory'
'help':'show the help messages'
'mutt-aliases':'export contacts as mutt aliases file'
'vcf-export':'export contacts as .vcf file'
'rename-all':'rename all contacts file according to their contents'
'rebuild':'rebuild the cache file'
)
_describe -t commands "contact commands" contact_ary -V contact_commands
}
local curcontext="$curcontext" state line
_arguments -C \
'1: :->command' \
'*:: :->options'
case $state in
(command)
_alternative \
_contact_commands \
;;
(options)
local -a contact_contacts
local contactdir=~/.contacts
contact_contacts=(
$contactdir/*(N)
)
contact_contacts=( ${contact_contacts#$contactdir/} )
_describe -t contacts "contact contacts" contact_contacts
;;
esac