#based off bash programable completion by Ian Macdonald
#and Gentoo  
if [ ${BASH_VERSINFO[1]} '>' 04 ]; then

shopt -s extglob progcomp
_gopen()
{
local APPS Applications curr appdirs 

APPS="Applications"

origdir="${PWD}"
COMPREPLY=()
curr=${COMP_WORDS[COMP_CWORD]}
#this is weird...
appdirs=`echo $GNUSTEP_PATHLIST: | sed -e "s/:/\/$APPS\/*.app /g"`
appdirs="$appdirs `echo ./*.app`" 
for i in $appdirs
do
	if [ -d $i ] 
	then
	Applications="$Applications `basename $i`"
	fi
done
COMPREPLY=($(compgen -W "`(echo $Applications)`" -- $curr ) ) 
}

complete -F _gopen openapp
complete -F _gopen gopen
else
echo "This script requires bash 2.0.4 you are running $BASHVERSINFO"

fi
