-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtab.rake
More file actions
35 lines (28 loc) · 698 Bytes
/
tab.rake
File metadata and controls
35 lines (28 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace :tab do
task :update do
tasks=Rake.application.tasks.map(&:name)
puts "#{autocomplete_script(tasks)}"
end
end
private
def autocomplete_script(tasks)
%Q{
# RakeTabCompletion
# Tab completion for rake tasks
_RakeTabCompletion ()
{
local cur colonprefixes
cur=${COMP_WORDS[COMP_CWORD]}
colonprefixes=${cur%"${cur##*:}"}
COMPREPLY=( $(compgen -W '#{tasks.join(' ')}' -- $cur))
# don't treat colons as seperators
# borrowed from darcs via Maven (http://i.willcode4beer.com/other/maven2)
local i=${#COMPREPLY[*]}
while [ $((--i)) -ge 0 ]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
done
return 0
} &&
complete -F _RakeTabCompletion rake
}
end