Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/bin/bash
  2. # file: UseGetOpt-2
  3. # UseGetOpt-2.sh parameter-completion
  4.  
  5. _UseGetOpt-2 ()   #  By convention, the function name
  6. {                 #+ starts with an underscore.
  7.   local cur
  8.   # Pointer to current completion word.
  9.   # By convention, it's named "cur" but this isn't strictly necessary.
  10.  
  11.   COMPREPLY=()   # Array variable storing the possible completions.
  12.   cur=${COMP_WORDS[COMP_CWORD]}
  13.  
  14.   case "$cur" in
  15.     -*)
  16.     COMPREPLY=( $( compgen -W '-a -d -f -l -t -h --aoption --debug \
  17.                               --file --log --test --help --' -- $cur ) );;
  18. #   Generate the completion matches and load them into $COMPREPLY array.
  19. #   xx) May add more cases here.
  20. #   yy)
  21. #   zz)
  22.   esac
  23.  
  24.   return 0
  25. }
  26.  
  27. complete -F _UseGetOpt-2 -o filenames ./UseGetOpt-2.sh
  28. #        ^^ ^^^^^^^^^^^^  Invokes the function _UseGetOpt-2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement