Skip to content

Instantly share code, notes, and snippets.

@qickstarter
Created February 19, 2013 08:16
Show Gist options
  • Save qickstarter/4983969 to your computer and use it in GitHub Desktop.
Save qickstarter/4983969 to your computer and use it in GitHub Desktop.
_cachefile_updated_at() {
echo $(stat -f "%c" .rake_tasks)
}
_rakefile_updated_at() {
echo $(stat -f "%c" Rakefile)
}
_gemfile_updated_at() {
echo $(stat -f "%c" Gemfile)
}
_generate_cachefile() {
if [ -f .rake_tasks ]; then
rm .rake_tasks
fi
rake --silent --tasks 2> /dev/null | cut -f 2 -d " " > .rake_tasks
}
_rake() {
if [ -f Rakefile ]; then
if [ ! -f .rake_tasks ] || \
[ `_cachefile_updated_at` -lt `_rakefile_updated_at` ] || \
[ -f Gemfile -a `_cachefile_updated_at` -lt `_gemfile_updated_at` ]; then
_generate_cachefile
fi
compadd `cat .rake_tasks`
fi
}
compdef _rake rake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment