function repos { if [[ $1 = "" ]] ; then cd ~/repos return fi cd ~/repos/$1 } function _repos { local allfiles=`find ~/repos/* -type d -maxdepth 0 -exec basename '{}' ';'` local array=(${(f)allfiles}) _describe -t commands "Projects" array return 1; } compdef _repos repos
参考