├── README.md └── rake-fast.plugin.zsh /README.md: -------------------------------------------------------------------------------- 1 | # rake-fast 2 | 3 | Fast rake autocompletion plugin for [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) 4 | 5 | **This plugin is now bundled with oh-my-zsh and maintained by more competent people [over there](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/rake-fast).** 6 | 7 | ## What? 8 | 9 | This script caches the output for later usage and significantly speeds it up. 10 | 11 | It generates a file .rake_tasks in parallel to the Rakefile. It also checks the file modification dates to see if it needs to regenerate the cache file. 12 | 13 | This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/), which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/). 14 | 15 | Think about that. 2006. 16 | 17 | ## How to install 18 | 19 | 1. Clone this repository in oh-my-zsh plugins directory: 20 | 21 | ```bash 22 | cd ~/.oh-my-zsh/custom/plugins 23 | git clone git://github.com/KevinBongart/rake-fast.git 24 | ``` 25 | 26 | 2. Add the plugin to your `.zshrc`: 27 | 28 | ```bash 29 | plugins=(foo bar rake-fast) 30 | ``` 31 | 32 | 3. Source `~/.zshrc` to take changes into account: 33 | 34 | ```bash 35 | source ~/.zshrc 36 | ``` 37 | 38 | You'll also want to add `.rake_tasks` to your [global .gitignore](https://help.github.com/articles/ignoring-files#global-gitignore) 39 | -------------------------------------------------------------------------------- /rake-fast.plugin.zsh: -------------------------------------------------------------------------------- 1 | # rake-fast (https://github.com/KevinBongart/rake-fast) 2 | # Fast rake autocompletion plugin for oh-my-zsh 3 | 4 | # This script caches the output for later usage and significantly speeds it up. 5 | # It generates a .rake_tasks file in parallel to the Rakefile. 6 | 7 | # You'll want to add `.rake_tasks` to your global .git_ignore file: 8 | # https://help.github.com/articles/ignoring-files#global-gitignore 9 | 10 | # You can force .rake_tasks to refresh with: 11 | # $ rake_refresh 12 | 13 | # This is entirely based on Ullrich Schäfer's work 14 | # (https://github.com/robb/.dotfiles/pull/10/), 15 | # which is inspired by this Ruby on Rails trick from 2006: 16 | # http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/ 17 | 18 | # Author: Kevin Bongart 19 | # contact@kevinbongart.net 20 | # http://kevinbongart.net 21 | # https://github.com/KevinBongart 22 | 23 | _rake_refresh () { 24 | if [ -f .rake_tasks ]; then 25 | rm .rake_tasks 26 | fi 27 | echo "Generating .rake_tasks..." > /dev/stderr 28 | _rake_generate 29 | cat .rake_tasks 30 | } 31 | 32 | _rake_does_task_list_need_generating () { 33 | if [ ! -f .rake_tasks ]; then return 0; 34 | else 35 | accurate=$(stat -f%m .rake_tasks) 36 | changed=$(stat -f%m Rakefile) 37 | return $(expr $accurate '>=' $changed) 38 | fi 39 | } 40 | 41 | _rake_generate () { 42 | rake --silent --tasks | cut -d " " -f 2 > .rake_tasks 43 | } 44 | 45 | _rake () { 46 | if [ -f Rakefile ]; then 47 | if _rake_does_task_list_need_generating; then 48 | echo "\nGenerating .rake_tasks..." > /dev/stderr 49 | _rake_generate 50 | fi 51 | compadd `cat .rake_tasks` 52 | fi 53 | } 54 | 55 | compdef _rake rake 56 | alias rake_refresh='_rake_refresh' 57 | --------------------------------------------------------------------------------