blob: 399563c005b030d35b2d632c7326e5ad07c76f7a (
plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# bash completion for slackpkg tool
# options list is based on `grep '\-.*\=.*)' /usr/sbin/slackpkg | cut -f1 -d\)`
_slackpkg()
{
local cur prev words cword
_init_completion -n = || return
local split=false
if [[ "$cur" == -?*=* ]]; then
prev="${cur%%?(\\)=*}"
cur="${cur#*=}"
split=true
fi
case "$prev" in
-delall|-checkmd5|-checkgpg|-checksize|-postinst|-onoff|-download_all|\
-dialog|-batch|-only_new_dotnew|-use_includes|-spinning)
COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
return 0
;;
-default_answer)
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
return 0
;;
-dialog_maxargs|-mirror)
# argument required but no completions available
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
compopt -o nospace
COMPREPLY=( $( compgen -W '-delall= -checkmd5= -checkgpg= \
-checksize= -postinst= -onoff= -download_all= -dialog= \
-dialog_maxargs= -batch= -only_new_dotnew= -use_includes= \
-spinning= -default_answer= -mirror=' -- "$cur" ) )
return 0
fi
local confdir="/etc/slackpkg"
local config="$confdir/slackpkg.conf"
if [ ! -r "$config" ]; then
return 0
fi
. "$config"
local i action
for (( i=1; i<${#words[@]}; i++ )); do
if [[ "${words[i]}" != -* ]]; then
action="${words[i]}"
break
fi
done
case "$action" in
generate-template|search|file-search)
# argument required but no completions available
return 0
;;
install-template|remove-template)
if [ -e "$confdir/templates" ]; then
COMPREPLY=( $( cd "$confdir/templates"; \
compgen -f -X "!*.template" -- "$cur" ) )
COMPREPLY=( ${COMPREPLY[@]%.template} )
fi
return 0
;;
remove)
_filedir
COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \
xap y' -- "$cur" ) )
COMPREPLY+=( $( cd /var/log/packages; compgen -f -- "$cur" ) )
return 0
;;
install|reinstall|upgrade|blacklist|download)
_filedir
COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \
xap y' -- "$cur" ) )
COMPREPLY+=( $( cut -f 6 -d\ ${WORKDIR}/pkglist 2> /dev/null | \
grep "^$cur" ) )
return 0
;;
info)
COMPREPLY+=( $( cut -f 6 -d\ ${WORKDIR}/pkglist 2> /dev/null | \
grep "^$cur" ) )
return 0
;;
update)
# we should complete the same as the next `list` + "gpg"
COMPREPLY=( $( compgen -W 'gpg' -- "$cur" ) )
;&
*)
COMPREPLY+=( $( compgen -W 'install reinstall upgrade remove \
blacklist download update install-new upgrade-all \
clean-system new-config check-updates help generate-template \
install-template remove-template search file-search info' -- \
"$cur" ) )
return 0
;;
esac
} && complete -F _slackpkg slackpkg
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
|