Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
6d4b0c6e
Commit
6d4b0c6e
authored
Oct 09, 2012
by
Robby Russell
Browse files
Merge pull request #1312 from koenpunt/fixes_cap_plugin
updated cap plugin to use `cap -T` instead of `cap show_tasks`
parents
c5a89058
9a4fac18
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/cap/cap.plugin.zsh
View file @
6d4b0c6e
function
_cap_does_task_list_need_generating
()
{
if
[
!
-f
.cap_tasks~
]
;
then return
0
;
stat
-f
%m
.
>
/dev/null 2>&1
if
[
"
$?
"
=
0
]
;
then
stat_cmd
=(
stat
-f
%m
)
else
stat_cmd
=(
stat
-L
--format
=
%y
)
fi
# Cache filename
_cap_show_undescribed_tasks
=
0
# Cache filename
_cap_task_cache_file
=
'.cap_task_cache'
_cap_get_task_list
()
{
if
[
${
_cap_show_undescribed_tasks
}
-eq
0
]
;
then
cap
-T
|
grep
'^cap'
|
cut
-d
" "
-f
2
else
cap
-vT
|
grep
'^cap'
|
cut
-d
" "
-f
2
fi
}
_cap_does_task_list_need_generating
()
{
if
[
!
-f
${
_cap_task_cache_file
}
]
;
then return
0
;
else
accurate
=
$(
stat
-f
%m .
cap_task
s~
)
changed
=
$(
stat
-f
%m
config/deploy.rb
)
accurate
=
$(
$
stat
_cmd
$_
cap_task
_cache_file
)
changed
=
$(
$
stat
_cmd
config/deploy.rb
)
return
$(
expr
$accurate
'>='
$changed
)
fi
}
...
...
@@ -10,12 +32,10 @@ function _cap_does_task_list_need_generating () {
function
_cap
()
{
if
[
-f
config/deploy.rb
]
;
then
if
_cap_does_task_list_need_generating
;
then
echo
"
\n
Generating .cap_tasks~..."
>
/dev/stderr
cap show_tasks
-q
|
cut
-d
" "
-f
1 |
sed
-e
'/^ *$/D'
-e
'1,2D'
>
.cap_tasks~
_cap_get_task_list
>
${
_cap_task_cache_file
}
fi
compadd
`
cat
.
cap_task
s~
`
compadd
`
cat
${
_
cap_task
_cache_file
}
`
fi
}
comp
ctl
-K
_cap cap
comp
def
_cap cap
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment