Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Licenced under GPL - Erwin Kwolek (erwin.kwolek@gmail.com)
- # This script makes a file in your / directory
- # It's the cache list of packages for your autocompletion
- # Init the top of the script
- program_begin='_myopkg()
- {
- local cur prev
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
- '
- # Init a loop
- program_if_begin=' if [[ ${cur} == '
- program_if_then='* ]] ; then
- COMPREPLY=( $(compgen -W "'
- program_if_end='" -- ${cur}) )
- return 0
- fi
- '
- # Init the program end
- program_end='
- }
- complete -F _myopkg opkg'
- # Open the cache file
- cache="/0pkg-completion"
- echo "$program_begin" > $cache
- 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
- do
- echo "Building auto-completion for packages begining with \"$letter\" letter. Please wait."
- packages=`opkg list | sed 's/ -.*//' | egrep "^$letter" | tr "\n" " "`
- # Each letter completion on a separate perfomance loop.
- echo "$program_if_begin$letter$program_if_then$packages$program_if_end" >> $cache
- done
- # Close the cache file
- echo "$program_end" >> $cache
- echo "Now you can run :"
- echo "bash"
- echo ". /0pkg-completion"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement