rake_completion.zsh 1.01 KB
Newer Older
1
_rake_does_task_list_need_generating () {
2
  if [ ! -f .rake_tasks~ ]; then return 0;
3
  else
4
5
    accurate=$(stat -c "%n" .rake_tasks~)
    changed=$(stat -c "%n" Rakefile)
6
7
8
9
10
11
12
    return $(expr $accurate '>=' $changed)
  fi
}

_rake () {
  if [ -f Rakefile ]; then
    if _rake_does_task_list_need_generating; then
13
14
      echo "\nGenerating .rake_tasks~..." > /dev/stderr
      rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~
15
    fi
16
    compadd `cat .rake_tasks~`
17
18
19
  fi
}

20
compctl -K _rake rake
21
22

function _cap_does_task_list_need_generating () {
23
  if [ ! -f .cap_tasks~ ]; then return 0;
24
  else
25
    accurate=$(stat -f%m .cap_tasks~)
26
27
28
29
30
31
32
33
    changed=$(stat -f%m config/deploy.rb)
    return $(expr $accurate '>=' $changed)
  fi
}

function _cap () {
  if [ -f config/deploy.rb ]; then
    if _cap_does_task_list_need_generating; then
34
      echo "\nGenerating .cap_tasks~..." > /dev/stderr
35
      cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
36
> .cap_tasks~
37
    fi
38
    compadd `cat .cap_tasks~`
39
40
41
  fi
}

42
compctl -K _cap cap