1 # Copyright (C) 2007 Andre Noll <maan@systemlinux.org>
3 # Licensed under the GPL v2. For licencing details see COPYING.
5 PC="para_client -l error -- "
14 __para_attributes_list=
18 local cur="${COMP_WORDS[COMP_CWORD]}"
22 COMPREPLY=($(compgen -P "$2" -W "$1" -- "$cur"))
25 __para_complete_file()
27 local cur="${COMP_WORDS[COMP_CWORD]}"
28 local sed_cmd="-e s|^\($cur[^/]\+/\).*|\1|1"
29 $PC ls -p -sp "${cur}*" | sed $sed_cmd | uniq
32 __para_complete_command()
34 if test -z "$__para_command_list"; then
35 __para_command_list="$($PC help | cut -f 1)"
37 echo "$__para_command_list"
40 __para_complete_table()
42 if test -z "$__para_table_list"; then
43 __para_table_list="$(ls $HOME/.paraslash/afs_database/)"
45 echo "$__para_table_list"
47 __para_complete_sender()
49 if test -z "$__para_sender_list"; then
50 __para_sender_list="$($PC si | grep "supported senders:" | sed -e 's/.*: //')"
52 echo "$__para_sender_list"
54 __para_complete_attribute()
56 if test -z "$__para_attributes_list"; then
57 __para_attributes_list="$($PC lsatt)"
59 echo "$__para_attributes_list"
61 __para_complete_playlist()
63 if test -z "$__para_playlist_list"; then
64 __para_playlist_list="$($PC lspl)"
66 echo "$__para_playlist_list"
68 __para_complete_mood()
70 if test -z "$__para_mood_list"; then
71 __para_mood_list="$($PC lsmood)"
73 echo "$__para_mood_list"
75 __para_complete_image()
77 if test -z "$__para_image_list"; then
78 __para_image_list="$($PC lsimg)"
80 echo "$__para_imagelist"
82 __para_complete_lyrics()
84 if test -z "$__para_lyrics_list"; then
85 __para_lyrics_list="$($PC lslyr)"
87 echo "$__para_lyrics_list"
92 local cur="${COMP_WORDS[COMP_CWORD]}"
95 __paracomp "$($PC lspl "${cur}*" | sed -e 's|^|p/|1') $($PC lsmood | sed -e 's|^|m/|1')"
102 local cur="${COMP_WORDS[COMP_CWORD]}"
103 if [ $COMP_CWORD -lt 3 ]; then
104 __paracomp "$(__para_complete_attribute)"
106 if test -z "$cur" -o "$cur" = "${cur#/}"; then
107 __paracomp "$(__para_complete_attribute)"
109 __paracomp "$(__para_complete_file)"
116 if test $COMP_CWORD -eq 2; then
117 __paracomp "$(__para_complete_sender)"
118 elif test $COMP_CWORD -eq 3; then
119 __paracomp "on off add delete allow deny help"
130 while [ $c -lt $COMP_CWORD ]; do
134 *) command="$i"; break ;;
139 if [ $c -eq $COMP_CWORD ]; then
140 case "${COMP_WORDS[COMP_CWORD]}" in
141 --*=*) COMPREPLY=();;
142 *) __paracomp "$(__para_complete_command)";;
148 stop|play|term|hup|pause|nomore|si|version) COMPREPLY=();;
149 setatt) __para_setatt;;
150 select) __para_select;;
151 touch|ls|rm|cpsi) __paracomp "$(__para_complete_file)";;
152 mvatt|lsatt|rmatt) __paracomp "$(__para_complete_attribute)";;
153 help) __paracomp "$(__para_complete_command)";;
154 sender) __para_sender;;
155 init) __paracomp __paracomp "$(__para_complete_table)";;
156 mvmood|lsmood|rmmood) __paracomp "$(__para_complete_mood)";;
157 mvlyr|lslyr|rmlyr) __paracomp "$(__para_complete_lyrics)";;
158 mvimg|lsimg|rmimg) __paracomp "$(__para_complete_image)";;
159 mvpl|lspl|rmpl) __paracomp "$(__para_complete_playlist)";;
163 complete -o default -o nospace -F _para_client para_client
164 complete -o default -o nospace -F _para_client para