forked from ushis/local-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_completion
39 lines (35 loc) · 962 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
have local-repo &&
_local-repo() {
local cur i
COMPREPLY=()
_get_comp_words_by_ref cur
# First arg must be a path
if [ ${#COMP_WORDS[@]} -le 2 ]; then
_filedir
return 0
fi
# check the last option
for ((i=${#COMP_WORDS[@]}; i > 1; i--)); do
case "${COMP_WORDS[i]}" in
-h|--help)
return 0
;;
-a|--add|-u|--upgrade)
_filedir
break
;;
-i|--info|-r|--remove|-s|--search)
COMPREPLY=( $( local-repo ${COMP_WORDS[1]} -s "$cur" 2>/dev/null\
| grep -v '::' | cut -d' ' -f2 ) )
break
;;
-A|--aur-add|-c|--check|-e|--elephant|-l|--list|-R|--restore|-U|--aur-upgrade)
break
;;
esac
done
COMPREPLY=( ${COMPREPLY[@]} $( compgen -W '--add --aur-add --check --elephant --help --info\
--list --remove --restore --search --upgrade\
--aur-upgrade' -- "$cur") )
} &&
complete -F _local-repo local-repo