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
|
# Copyright (c) 2010, 2011 Jack Kaliko <efrim@azylum.org> {{{
#
# This file is part of MPD_sima
#
# MPD_sima is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MPD_sima is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MPD_sima. If not, see <http://www.gnu.org/licenses/>.
#
#
# }}}
# Bash completion file
#
# On debian system either place this file in etc/bash_completion.d/ or source it
# in your barshrc.
_sima() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-c --config -p --pid -l --log -S --host -P --mpd_port --new-version -h --help --version --var_dir"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
case "${prev}" in
-p|--pid|-l|--log|--var_dir)
COMPREPLY=( $(compgen -f ${cur}) )
;;
-c|--config)
if [ -z $XDG_DATA_HOME ]; then
local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg) ; do echo "${x##*//}"; done)
else
local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg $XDG_DATA_HOME/mpd_sima/*.cfg) ; do echo "${x##*//}"; done)
fi
COMPREPLY=( $(compgen -W "${confnames}" -- ${cur}) $(compgen -f ${cur}) )
return 0
;;
--host|-S)
COMPREPLY=( $(compgen -A hostname ${cur}) )
;;
*)
;;
esac
}
complete -F _sima mpd_sima
complete -F _sima mpd-sima
_art_names_list() {
local IFS=$'\n'
compgen -W "${artists}" -- ${cur}
}
_simadb_cli() {
local cur prev opts artists
local IFS=$'\n'
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--add_similarity -a --remove_similarity --remove_artist \
--purge_hist --view_artist --view_all \
--bl_curr_trk --bl_curr_art --bl_curr_al --bl_art --remove_bl --view_bl \
--dbfile -d \
--host -S --port -P \
--reciprocal -r --check_names -c \
--version -h --help"
opts=$(echo $opts | sed 's/ /\n/g')
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
case "${prev}" in
--bl_curr*|--view_bl|--view_all|--purge_hist|--version|--help|-h)
return 0
;;
-d|--dbfile)
COMPREPLY=( $(compgen -f ${cur}) )
;;
--host|-S)
COMPREPLY=( $(compgen -A hostname ${cur}) )
;;
-a|--add_similarity|--view_artist|-v|--bl_art)
if [ -x /usr/bin/mpc ]; then
artists=$(for x in $(/usr/bin/mpc list artist) ; do echo "'${x}'"; done)
COMPREPLY=( $(compgen -W "${artists}" -- ${cur}) )
return 0
fi
# It should also complete artist name when the string ends with a comma
return 0
;;
*)
;;
esac
}
complete -F _simadb_cli simadb_cli
|