Guest User

Untitled

a guest
Jan 28th, 2015
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.77 KB | None | 0 0
  1. # adding music
  2. _mcp_add () {
  3.     #local IFS=$'\n'
  4.     while IFS= read -r -u3 -d $'\0' completion; do
  5.     COMPREPLY+=( "$completion" )
  6.     done 3< <(mcp complete "$(eval echo "$cur")" | __escape_strings_stdin)
  7.     compopt -o nospace
  8. }
  9.  
  10. # Main completion function
  11. _mcp () {
  12.     local c=1 word command
  13.     local IFS=$' \t\n'
  14.  
  15.     cur="${COMP_WORDS[COMP_CWORD]}"
  16.  
  17.     if test $COMP_CWORD = 1 ; then
  18.         COMPREPLY=( $(compgen -W "add play toggle pause stop next prev playlist current status volume clear skip delete seek" -- "$cur") )
  19.         if [[ ${#COMPREPLY[@]} = 0 ]] ; then
  20.             _mcp_add
  21.         fi
  22.  
  23.     else
  24.  
  25.         command="${COMP_WORDS[1]}"
  26.  
  27.         # Complete command arguments
  28.         case "$command" in
  29.         add|a)       _mcp_add ;;
  30.         play|p)      _mcp_add ;;
  31.         *)           ;;
  32.         esac
  33.  
  34.     fi
  35.  
  36. }
  37. complete -F _mcp mcp
Advertisement
Add Comment
Please, Sign In to add comment