[lastbash-cvs] lastbash lastbash.bash_completion,NONE,1.1
Status: Beta
Brought to you by:
cstroie
|
From: Costin S. <cs...@us...> - 2006-12-08 17:53:11
|
Update of /cvsroot/lastbash/lastbash In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30038 Added Files: lastbash.bash_completion Log Message: Initial support for bash completion. --- NEW FILE: lastbash.bash_completion --- # LastBASH bash_completion file # Copyright (C) 2006 Costin Stroie <cs...@us...> # # This program 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. # # $Id: lastbash.bash_completion,v 1.1 2006/12/08 17:53:08 cstroie Exp $ function _lastbash() { local current prev list COMPREPLY=() current=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} cmd="${COMP_WORDS[0]}" #echo "CURRENT: $current" >> /tmp/comp if [ "$prev" == -g ] then list="$($cmd -g help)" elif [ "$prev" == -p ] then list="$($cmd -p help)" elif [ "$prev" == -c ] then list="SKIP BAN LOVE REFRESH RTP DISCOVERY DEBUG WINCH QUIT" elif [ "$prev" == -r ] then list="" else if [[ "$current" == -* ]] then list="-a -A -d -g -p -r -u -c -v -h" elif [[ "$current" =~ ^lastfm:// ]] then _lastbash_url return 0 else list="lastfm://" fi fi if [ "$list" ] then COMPREPLY=( $(compgen -W "$list" -- $current) ) else COMPREPLY=() fi return 0 } function _lastbash_url() { local C L S declare -a U if [ "$current" == "lastfm://" ] then C="" else C="${current%/}" C="${C##*/}" fi #echo "C: ${C}" >> /tmp/comp S="${current##lastfm://}" U=(${S//\// }) #echo "U: ${U}" >> /tmp/comp #echo "U#: ${#U[@]}" >> /tmp/comp if [ "${U[0]}" ] then case "${U[0]}" in "globaltags") if [ "${U[1]}" ] then L="" else L="rock metal progressive" fi ;; "group") if [ "${U[1]}" ] then L="" else L="LastBASH Linux Amarok" fi ;; "user") if [ "${U[1]}" ] then if [ "${U[2]}" ] then L="" else L="recommended neighbours personal loved" fi else L="cstroie mscarlat dbordeanu" fi ;; "usertags") if [ "${U[1]}" ] then if [ "${U[2]}" ] then L="" else L="rock metal guitar" fi else L="RJ" fi ;; "artist") if [ "${U[1]}" ] then if [ "${U[2]}" ] then L="" else L="similarartists fans" fi else L="Rammstein Pink%20Floyd Yes" fi ;; "play") if [ "${U[1]}" ] then L="" else L="tracks" fi ;; *) L="globaltags group user usertags artist play" ;; esac else L="globaltags group user usertags artist play" fi #echo "L: ${L}" >> /tmp/comp COMPREPLY=( $(compgen -W "$L" -- $C) ) #echo "COMPLETION: ${COMPREPLY[@]}" >> /tmp/comp #COMPREPLY=() } complete -F _lastbash lastbash |