click-complete.bash 678 B

1234567891011121314151617181920212223242526272829
  1. _click_completion() {
  2. local IFS=$'\n'
  3. local response
  4. response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _FLEXMEASURES_COMPLETE=bash_complete $1)
  5. for completion in $response; do
  6. IFS=',' read type value <<< "$completion"
  7. if [[ $type == 'dir' ]]; then
  8. COMREPLY=()
  9. compopt -o dirnames
  10. elif [[ $type == 'file' ]]; then
  11. COMREPLY=()
  12. compopt -o default
  13. elif [[ $type == 'plain' ]]; then
  14. COMPREPLY+=($value)
  15. fi
  16. done
  17. return 0
  18. }
  19. _click_completion_setup() {
  20. complete -o nosort -F _click_completion flexmeasures
  21. }
  22. _click_completion_setup;