Update: new rake and capistrano bash completion
Rake task completion is awesome. A quick google search will hook you up … (here’s one)
Rake completion must invoke rake and that can be SLOW. I use completion to save time … What’s the point on having bash freeze on rake -T for longer than it would take me to type the whole thing?
I took it upon myself to cache the output of rake -T and to use that if it’s available.
function _check_rakefile() {
if [ ! -e Rakefile ]; then
return
fi
if [ -e ".rake_t_cache" ]; then
local tasks=`cat .rake_t_cache | awk ‘{print $2}‘`
else
local tasks=`rake –silent -T | awk ‘{print $2}‘`
fi
COMPREPLY=( $(compgen -W "${tasks}" – $2) )
}
complete -F _check_rakefile -o default rake
The magic is in the .rake_t_cache file. If it’s there, use it, if not … well … we haven’t gained/lost anything, the regular completion behavior is still in place.
Where does .rake_t_cache come from?
function rake_cache() {
rake -T > .rake_t_cache
}
function rake_cache_clear() {
if [ -e ".rake_t_cache" ]; then
rm .rake_t_cache
fi
}
I have been thinking about a way to detect when the cache file needs to be regenerated. However, I leave it in the capable hands of the user. All the time saved completing tasks with the cache will compensate for the inevitable time when the cache will be stale and swear words will be required.
[...] I’ve posted about my rake script to do completion in bash before, that was a while back and I’ve improved things [...]
Hello! this is the best show case of one fine wp template right? seems all so organized that it even makes me think its more than perfect! fine posts btw, waiting for more!
!
I just registered here….
. .
Is it hard to become a moderator here?
just visit interesting info
[...] rake -T on each invocation, it was unusably slow. Another search found Jonathan Palardy’s implementation with caching. [...]