Squashed 'oh-my-zsh/' content from commit 550ccca
git-subtree-dir: oh-my-zsh git-subtree-split: 550ccca91cb45fcf26a8f2c3c60da675b995e3f3
This commit is contained in:
23
plugins/rake-fast/README.md
Normal file
23
plugins/rake-fast/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# rake-fast
|
||||
|
||||
Fast rake autocompletion plugin.
|
||||
|
||||
This script caches the output for later usage and significantly speeds it up. It generates a .rake_tasks cache file in parallel to the Rakefile. It also checks the file modification dates to see if it needs to regenerate the cache file.
|
||||
|
||||
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/).
|
||||
|
||||
Think about that. 2006.
|
||||
|
||||
## Installation
|
||||
|
||||
Just add the plugin to your `.zshrc`:
|
||||
|
||||
```bash
|
||||
plugins=(foo bar rake-fast)
|
||||
```
|
||||
|
||||
You might consider adding `.rake_tasks` to your [global .gitignore](https://help.github.com/articles/ignoring-files#global-gitignore)
|
||||
|
||||
## Usage
|
||||
|
||||
`rake`, then press tab
|
||||
39
plugins/rake-fast/rake-fast.plugin.zsh
Normal file
39
plugins/rake-fast/rake-fast.plugin.zsh
Normal file
@@ -0,0 +1,39 @@
|
||||
_rake_refresh () {
|
||||
if [ -f .rake_tasks ]; then
|
||||
rm .rake_tasks
|
||||
fi
|
||||
echo "Generating .rake_tasks..." > /dev/stderr
|
||||
_rake_generate
|
||||
cat .rake_tasks
|
||||
}
|
||||
|
||||
_rake_does_task_list_need_generating () {
|
||||
if [ ! -f .rake_tasks ]; then return 0;
|
||||
else
|
||||
if [[ "$OSTYPE" = darwin* ]]; then
|
||||
accurate=$(stat -f%m .rake_tasks)
|
||||
changed=$(stat -f%m Rakefile)
|
||||
else
|
||||
accurate=$(stat -c%Y .rake_tasks)
|
||||
changed=$(stat -c%Y Rakefile)
|
||||
fi
|
||||
return $(expr $accurate '>=' $changed)
|
||||
fi
|
||||
}
|
||||
|
||||
_rake_generate () {
|
||||
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
|
||||
}
|
||||
|
||||
_rake () {
|
||||
if [ -f Rakefile ]; then
|
||||
if _rake_does_task_list_need_generating; then
|
||||
echo "\nGenerating .rake_tasks..." > /dev/stderr
|
||||
_rake_generate
|
||||
fi
|
||||
compadd `cat .rake_tasks`
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _rake rake
|
||||
alias rake_refresh='_rake_refresh'
|
||||
Reference in New Issue
Block a user