Advertisement
freephile

Acrobat Fail

Mar 28th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cat /etc/bash_completion.d/acroread.sh
  2. # _filedir : to handle file and directories with spaces in their names.
  3.  
  4. _filedir()
  5. {
  6.         local IFS=$'\t\n' xspec #glob
  7.  
  8.         #glob=$(set +o|grep noglob) # save glob setting.
  9.         #set -f          # disable pathname expansion (globbing)
  10.  
  11.         xspec=${1:+"!*.$1"}     # set only if glob passed in as $1
  12.         COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \
  13.                     $( compgen -d -- "$cur" ) )
  14.         #eval "$glob"    # restore glob setting.
  15. }
  16.  
  17. _acroread()
  18. {
  19.         local cur prev opts files
  20.         COMPREPLY=()
  21.         cur="${COMP_WORDS[COMP_CWORD]}"
  22.         #prev="${COMP_WORDS[COMP_CWORD-1]}"
  23.         first="${COMP_WORDS[1]}"
  24.         #
  25.         #  The basic options we'll complete.
  26.         #
  27.         opts="--display --screen --sync -geometry -help -man -iconic -setenv -tempFile -tempFileTitle -toPostScript -openInNewWindow -installCertificate -v -version"
  28.  
  29.         #
  30.         #  Complete the arguments to some of the basic commands.
  31.         #
  32.         case "${first}" in
  33.         -toPostScript)
  34.         if [[ "${cur}" == -* ]]; then
  35.         local running="-binary -start -end -pairs -optimizeForSpeed -landscape -reverse -odd -even -commentsOff -annotsOff -stampsOff -markupsOn -level2 -level3 -printerhalftones -saveVM -size -shrink  -expand -transQuality -printerName -nUp -booklet -rotateAndCenter -choosePaperByPDFPageSize"
  36.         COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  37.         return 0
  38.         fi
  39.         ;;
  40.  
  41.         -installCertificate)
  42.         if [[ "${cur}" == -* ]]; then
  43.           if [ $COMP_CWORD -eq 2 ]; then
  44.             local running="-PEM -DER"
  45.             COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  46.             return 0
  47.           fi
  48.         fi
  49.         ;;
  50.  
  51.         *)
  52.         ;;
  53.         esac
  54.  
  55.  
  56.         if [[ "${cur}" == -* ]] ; then
  57.           COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))  
  58.           return 0
  59.         fi
  60.  
  61.         if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
  62.         _filedir '[pP][dD][fF]'
  63.         fi
  64.  
  65. }
  66. complete -o filenames -o nospace -F _acroread acroread
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement