1# Simple bash completion rules for the haikuporter script 2# 3# To install: copy this file to the /etc/bash_completion.d directory 4# 5 6function _hp_options 7{ 8local options="$(haikuporter -h | grep -- -- | cut -f3,4 -d' ' | sed -e 's/, / /')" 9COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$options' -- "$cur")) 10} 11 12function _hp_beps 13{ 14 local packages 15 16 for i in "$(haikuporter -t)"/*/*/*.bep; do 17 i="${i##*/}" 18 packages="${i%.bep} ${packages}" 19 done 20 21 COMPREPLY=( $(compgen -W '${packages}' -- ${cur}) ) 22} 23 24function _haikuporter() 25{ 26 local cur=${COMP_WORDS[COMP_CWORD]} 27 28 # Stop offering completions when one of these is in the previous argument. 29 case ${COMP_WORDS[COMP_CWORD-1]} in 30 --version|-h|--help|-s|--search|-l|--list|-g|--get|-t|--tree) 31 return 0 32 ;; 33 esac 34 35 if [[ ${cur} == -* ]];then 36 _hp_options 37 return 38 fi 39 40 _hp_beps 41 42 return 0 43} 44complete -F _haikuporter -o filenames haikuporter 45