Monday, February 18, 2008

rake zsh




The completed code for fast rake task completion for zsh on Linux (Fedora 7) with coreutils-5.2.1 is:


function _rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks ]; then
return 0;
else
accurate=$(stat -c%m .rake_tasks)
changed=$(stat -c%m Rakefile)
return $(expr $accurate '>=' $changed)
fi
}

function _rake () {
if [ -f Rakefile ]; then
if _rake_does_task_list_need_generating; then
echo "\nGenerating .rake_tasks..." > /dev/stderr
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
fi
reply=( `cat .rake_tasks` )
fi
}

compctl -K _rake rake


Save this as a file (I put mine in my ~/bin directory) and source it with:


. ~/bin/zsh-rake-fast-completion