Advertisement
Guest User

kaoul

a guest
Sep 28th, 2008
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.19 KB | None | 0 0
  1. # Licenced under GPL - Erwin Kwolek (erwin.kwolek@gmail.com)
  2. # This script makes a file in your / directory
  3. # It's the cache list of packages for your autocompletion
  4.  
  5. # Init the top of the script
  6. program_begin='_myopkg()
  7. {
  8.    local cur prev
  9.    COMPREPLY=()
  10.    cur="${COMP_WORDS[COMP_CWORD]}"
  11.    prev="${COMP_WORDS[COMP_CWORD-1]}"
  12.  
  13. '
  14.  
  15. # Init a loop
  16. program_if_begin='        if [[ ${cur} == '
  17. program_if_then='* ]] ; then
  18.        COMPREPLY=( $(compgen -W "'
  19. program_if_end='" -- ${cur}) )
  20.        return 0
  21.    fi
  22. '
  23.  
  24. # Init the program end
  25. program_end='
  26. }
  27. complete -F _myopkg opkg'
  28.  
  29.  
  30. # Open the cache file
  31. cache="/0pkg-completion"
  32. echo "$program_begin" > $cache
  33.  
  34.  
  35. for letter in a b c d e f g h i j k l m n o p q r s t u v w x y z
  36. do
  37.     echo "Building auto-completion for packages begining with \"$letter\" letter. Please wait."
  38.     packages=`opkg list | sed 's/ -.*//' | egrep "^$letter" | tr "\n" " "`
  39.  
  40.     # Each letter completion on a separate perfomance loop.
  41.     echo "$program_if_begin$letter$program_if_then$packages$program_if_end" >> $cache
  42. done
  43.  
  44. # Close the cache file
  45. echo "$program_end" >> $cache
  46.  
  47.  
  48. echo "Now you can run :"
  49. echo "bash"
  50. echo ". /0pkg-completion"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement