diff --git a/zsh/rake_completion b/zsh/rake_completion new file mode 100644 index 0000000..3f2d483 --- /dev/null +++ b/zsh/rake_completion @@ -0,0 +1,20 @@ +_rake_does_task_list_need_generating () { + if [ ! -f .rake_tasks ]; then return 0; + else + accurate=$(stat -f%m .rake_tasks) + changed=$(stat -f%m Rakefile) + return $(expr $accurate '>=' $changed) + fi +} + +_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 + compadd `cat .rake_tasks` + fi +} + +compdef _rake rake \ No newline at end of file diff --git a/zsh/zshrc b/zsh/zshrc index e2e9224..03e2f1b 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -13,6 +13,9 @@ source $DOT_FILES/zsh/config # Rake completion source $DOT_FILES/zsh/completions +# Rake completion +source $DOT_FILES/zsh/rake_completion + # My custom theme source $DOT_FILES/zsh/theme