-
Notifications
You must be signed in to change notification settings - Fork 4
/
bash-completion
39 lines (33 loc) · 975 Bytes
/
bash-completion
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
# Bash completion for aurvote
#
# This file is part of aurvote
_aurvote() {
local cur prev words cword
_init_completion || return
local options='\
--check -c
--configure
--help -h
--unvote -u
--version -V
--vote -v
'
# First parameter should be an option
if ((cword == 1)); then
COMPREPLY=($(compgen -W "$options" -- "$cur"))
return 0
fi
# Try to complete package name after relevant options
if [[ $prev =~ ^-[cuv]$ ]] || [[ $prev =~ ^--(check|(un)?vote)$ ]]; then
# Use aurtab cache if available (https://github.com/worzel666/aurtab)
local aurtab_cache=$HOME/.cache/aurtab/pkglist.gz
if [ -f $aurtab_cache ]; then
COMPREPLY=($(compgen -W "$(command gzip -cd $aurtab_cache)" -- "$cur"))
# Fallback to foreign packages
else
COMPREPLY=($(compgen -W "$(command pacman -Qqm)" -- "$cur"))
fi
fi
}
complete -F _aurvote aurvote
# vi: set ft=sh ts=2 sw=2 et: