Package: cdcd
Severity: wishlist
Hi,
attached please find a simple function for bash completion for the
cdcd command. I'd be glad if it would be added to future versions.
License is GPLv2 or higher, same as for cdcd itself.
Regards,
Joey
--
It's practically impossible to look at a penguin and feel angry.
Please always Cc to me when replying to me on the lists.
# put this in your bashrc for bash tab completion with mpc
# $ cat cdcd-bashrc >> ~/.bashrc
ismember()
{
local elm="$1"; shift
local pivot
for pivot in $*
do
if [ "$pivot" = "$elm" ]
then
return 0
fi
done
return 1
}
_cdcd_complete_func ()
{
cur="${COMP_WORDS[COMP_CWORD]}"
first=${COMP_WORDS[1]}
second=${COMP_WORDS[2]}
commands=`cdcd help|grep -v 'For more'`
commands=${commands#Commands: }
commands=${commands//,/}
commands=${commands/./}
if ismember "$first" $commands
then
COMPREPLY=""
return 0
fi
case "$first" in
*)
COMPREPLY=($(compgen -W "${commands}" ${cur}))
return 0
;;
esac
}
complete -F _cdcd_complete_func cdcd