1 # Copyright (c) 2010, 2011, 2013, 2014 Jack Kaliko <kaliko@azylum.org>
3 # This file is part of MPD_sima
5 # MPD_sima is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # MPD_sima is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with MPD_sima. If not, see <http://www.gnu.org/licenses/>.
20 # Bash completion file
22 # On debian system either place this file in etc/bash_completion.d/ or source it
28 _get_comp_words_by_ref cur prev
38 if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
39 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
48 COMPREPLY=( $(compgen -W "debug info warning error" -- ${cur} ))
55 if [ -z $XDG_DATA_HOME ]; then
56 local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg 2>/dev/null) ; do echo "${x##*//}"; done)
58 local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg $XDG_DATA_HOME/mpd_sima/*.cfg 2>/dev/null) ; do echo "${x##*//}"; done)
60 COMPREPLY+=( $(compgen -W "${confnames}") )
64 COMPREPLY=( $(compgen -A hostname ${cur}) )
70 complete -F _sima mpd_sima
71 complete -F _sima mpd-sima
75 compgen -W "${artists}" -- ${cur}
79 local cur prev opts artists
82 _get_comp_words_by_ref cur prev
83 opts="--add_similarity -a --remove_similarity --remove_artist \
84 --purge_hist --view_artist --view_all \
85 --bl_curr_trk --bl_curr_art --bl_curr_al --bl_art --remove_bl --view_bl \
88 --reciprocal -r --check_names -c \
90 opts=$(echo $opts | sed 's/ /\n/g')
92 if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
93 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
98 --bl_curr*|--view_bl|--view_all|--purge_hist|--version|--help|-h)
105 COMPREPLY=( $(compgen -A hostname ${cur}) )
107 -a|--add_similarity|--view_artist|-v|--bl_art)
108 if [ -x /usr/bin/mpc ]; then
109 artists=$(for x in $(/usr/bin/mpc list artist) ; do echo "'${x}'"; done)
110 COMPREPLY=( $(compgen -W "${artists}" -- ${cur}) )
113 # It should also complete artist name when the string ends with a comma
120 complete -F _simadb_cli simadb_cli