/bash_completion_lib/complete -o filenames -o nospace/perl

http://github.com/brinkman83/bashrc · #! · 45 lines · 38 code · 7 blank · 0 comment · 0 complexity · d245099e90e6a56966dd525625cec0a5 MD5 · raw file

  1. comp_include _filedir _get_cword _perlmodules
  2. _perl()
  3. {
  4. local cur optPrefix optSuffix prev prefix temp
  5. COMPREPLY=()
  6. cur=`_get_cword`
  7. prev=${COMP_WORDS[COMP_CWORD-1]}
  8. prefix=""
  9. # If option not followed by whitespace, reassign prev and cur
  10. if [[ "$cur" == -?* ]]; then
  11. temp=$cur
  12. prev=${temp:0:2}
  13. cur=${temp:2}
  14. optPrefix=-P$prev
  15. optSuffix=-S/
  16. prefix=$prev
  17. fi
  18. case "$prev" in
  19. -I|-x)
  20. local IFS=$'\t\n'
  21. COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- "$cur" ) )
  22. return 0
  23. ;;
  24. -m|-M)
  25. _perlmodules
  26. return 0
  27. ;;
  28. esac
  29. # handle case where first parameter is not a dash option
  30. if [[ "`_get_cword`" != -* ]]; then
  31. _filedir
  32. return 0
  33. fi
  34. # complete using basic options
  35. COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
  36. -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
  37. return 0
  38. } # _perl()