1 #-*- mode: shell-script; tab-width: 4-*-
4 # Copyright 2005 Remi Vanicat
6 # License: GNU GPL v2 or later
10 local cmd cur prev query i saveifs
14 cur=${COMP_WORDS[COMP_CWORD]}
15 prev=${COMP_WORDS[COMP_CWORD-1]}
17 if [ $COMP_CWORD -eq 1 ]; then
18 COMPREPLY=( $(compgen -W "add addarg addid insert insertid radd rinsert clear shuffle \
19 sort remove list addpls play stop toggleplay pause next prev seek \
20 jump move volume volume_list mlib playlist coll browse status info \
21 current config config_list plugin_list stats quit help" -- "$cur") )
27 case "$cmd$COMP_CWORD" in
29 COMPREPLY=( $(compgen -W "add loadall searchadd search addpath rehash remove setstr setint rmprop addcover" -- "$cur") )
32 list_playlist3|save_playlist3|load_playlist3|import_playlist3|export_playlist3|remove_playlist3)
33 COMPREPLY=($(compgen -W "$(xmms2 mlib playlists_list)" \
44 if [[ "$cur" == *=* ]]; then
47 cur=$(echo "${cur#*=}" | sed -e 's/\\//g' | sed -e "s/'/''/g")
48 query="select value from Media \
49 where key='$prev' and value like '$cur%' \
50 group by lower(value) order by lower(value)"
53 COMPREPLY=( $(xmms2 mlib query "$query"|cut -c 9- )) # | sed -e 's/ /\\ /g' | sed -e "s/'/\\\\'/g") )
54 for (( i=0; ${#COMPREPLY[@]} - i; i=i+1 )); do
55 COMPREPLY[i]="$(printf '%q' "${COMPREPLY[i]}")"
61 COMPREPLY=($(compgen -W "$(xmms2 mlib query 'select distinct key from Media' | sed 's/^key = \(.*\)$/\1/')" -- "$cur" | sed 's/$/=/'))
67 if [ $COMP_CWORD -eq 2 ]; then
68 COMPREPLY=($(compgen -W "$(xmms2 config_list | sed 's/ .*//')"))
73 if [ $COMP_CWORD -eq 2 ]; then
74 COMPREPLY=($(compgen -W "save rename list query queryadd find get remove attr sync"))
79 if [ $COMP_CWORD -eq 2 ]; then
80 COMPREPLY=($(compgen -W "$(xmms2 mlib playlists_list)"))
85 if [ $COMP_CWORD -eq 2 ]; then
86 COMPREPLY=($(compgen -W "list active create type load remove"))
91 if [ $COMP_CWORD -eq 2 ]; then
92 COMPREPLY=($(compgen -W "artist title duration album \
93 laststarted lmod mime added url bitrate tracknr album_id \
107 complete -F _xmms2 -o default xmms2