forked from rmarquis/pacaur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash.completion
48 lines (43 loc) · 1.45 KB
/
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
40
41
42
43
44
45
46
47
48
#!/bin/bash
#
# /usr/share/bash-completion/completions/pacaur
#
_cower_pkg() {
# at least 2 characters required due to AUR limitation
COMPREPLY+=($(compgen -W "$(cower -sq -- ^$cur 2>/dev/null)" -- $cur))
}
_pacaur() {
# define variables
local cur op o
COMPREPLY=()
cur=$(_get_cword)
if ((COMP_CWORD == 1)); then
if [[ $cur != -* ]]; then
_pacman_file; return 0;
else
_pacman &> /dev/null
_arch_compgen "${COMPREPLY[@]}" "-s --search -i --info -d --download -m --makepkg -y --sync -k --check -u --update -v --version -h --help"
return 0
fi
fi
for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade' 'i info' 'd download' 'm makepkg' 'y sync' 'k check' 'u update'; do
_arch_incomp "$o" && break
done
(($?)) && op="" || op="${o% *}"
_pacman &> /dev/null
if [[ "$cur" == -* ]]; then
case "$op" in
S) _arch_compgen "${COMPREPLY[@]}" "-a --aur -r --repo -e --edit --devel --domain --foreign --noconfirm --noedit --rebuild --silent";;
Q) _arch_compgen "${COMPREPLY[@]}" "-a --aur -r --repo";;
esac
else
case "$op" in
# S) _pacman_pkg Slq; _cower_pkg;; # disabled. Too slow and no fallback var support.
d|i|m|y) _cower_pkg;;
k|u) _pacman_pkg Qqm;;
esac
fi
}
_completion_loader pacman
complete -o default -F _pacaur pacaur
# vim:set ts=4 sw=2 et: