#!/usr/bin/env bash function acd { local pkg_path pkg_path=$(autoproj locate $1) if [ $? != 0 ]; then return 1 else pkg_path=$(echo $pkg_path | tail -1) cd $pkg_path return 0 fi } type -p _get_comp_words_by_ref || return 1 _autoproj_installed_packages() { local packages="`ruby 2>/dev/null </dev/null && "$completions_func" return 0 ;; esac (( counter++ )) done return 1 } _autoproj_to_alternatives() { local parts=( $1 ) local IFS='|' echo "${parts[*]}" } _autoproj_to_extglob() { local extglob=$( _autoproj_to_alternatives "$1" ) echo "@($extglob)" } _acd() { local cur prev words cword _get_comp_words_by_ref -n : cur prev words cword case "$cword" in 1) _autoproj_installed_packages ;; *) COMPREPLY=() ;; esac } complete -F _acd acd