Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lilv.bash_completion 1.9KB

12 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Bash auto-completion script written for lv2info and lv2jack.
  2. # Could be adapted to any other program that takes an
  3. # LV2 plugin URI as parameter.
  4. # Updated for Lilv by David Robillard <d@drobilla.net> on 2012-01-08.
  5. # Written by Lars Luthman <lars.luthman@gmail.com> on 2009-10-12.
  6. # No copyright claimed for this script. Do what you want with it.
  7. # For some reason Bash splits the command line not only at whitespace
  8. # but also at ':' signs before putting the parts into COMP_WORDS.
  9. # Since ':' is used in all URIs, which are what we want to complete,
  10. # we have to put the URI back together before we can complete it
  11. # and then cut off the parts we prepended from the completions.
  12. # It probably breaks in some special cases but for most common uses
  13. # it should work fine.
  14. function _lv2info() {
  15. local uri cur opts w wn raw_reply len type
  16. opts=`lv2ls | xargs -n1 echo -n " "`
  17. # This is the last "word", as split by Bash.
  18. cur="${COMP_WORDS[COMP_CWORD]}"
  19. w="$cur"
  20. # Add the previous word while it or this one is a word break character
  21. for i in `seq $(( $COMP_CWORD - 1 )) -1 1`; do
  22. wn="${COMP_WORDS[i]}"
  23. if expr "$COMP_WORDBREAKS" : ".*$wn" > /dev/null; then
  24. if expr "$COMP_WORDBREAKS" : ".*$w" > /dev/null; then
  25. break
  26. fi
  27. fi
  28. w="$wn"
  29. uri="$w$uri"
  30. done
  31. # Check the length of the words we prepend
  32. len=${#uri}
  33. uri="$uri$cur"
  34. raw_reply="$(compgen -W "${opts}" -- ${uri})"
  35. # If we are listing alternatives, just print the full URIs.
  36. type=`echo $COMP_TYPE | awk '{ printf "%c", $1 }'`
  37. if expr "?!@%" : ".*$type" > /dev/null; then
  38. COMPREPLY=( $raw_reply )
  39. return 0
  40. fi
  41. # Otherwise, strip the prepended words from all completion suggestions.
  42. COMPREPLY=()
  43. for i in $raw_reply; do
  44. COMPREPLY=( ${COMPREPLY[@]} ${i:len} )
  45. done
  46. }
  47. complete -F _lv2info lv2info
  48. # And the same for lv2jack.
  49. complete -F _lv2info lv2jack