mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-30 01:30:08 +00:00
Merge pull request #1312 from koenpunt/fixes_cap_plugin
updated cap plugin to use `cap -T` instead of `cap show_tasks`
This commit is contained in:
commit
6d4b0c6e56
1 changed files with 29 additions and 9 deletions
|
@ -1,8 +1,30 @@
|
||||||
function _cap_does_task_list_need_generating () {
|
stat -f%m . > /dev/null 2>&1
|
||||||
if [ ! -f .cap_tasks~ ]; then return 0;
|
if [ "$?" = 0 ]; then
|
||||||
|
stat_cmd=(stat -f%m)
|
||||||
else
|
else
|
||||||
accurate=$(stat -f%m .cap_tasks~)
|
stat_cmd=(stat -L --format=%y)
|
||||||
changed=$(stat -f%m config/deploy.rb)
|
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_cmd $_cap_task_cache_file)
|
||||||
|
changed=$($stat_cmd config/deploy.rb)
|
||||||
return $(expr $accurate '>=' $changed)
|
return $(expr $accurate '>=' $changed)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -10,12 +32,10 @@ function _cap_does_task_list_need_generating () {
|
||||||
function _cap () {
|
function _cap () {
|
||||||
if [ -f config/deploy.rb ]; then
|
if [ -f config/deploy.rb ]; then
|
||||||
if _cap_does_task_list_need_generating; then
|
if _cap_does_task_list_need_generating; then
|
||||||
echo "\nGenerating .cap_tasks~..." > /dev/stderr
|
_cap_get_task_list > ${_cap_task_cache_file}
|
||||||
cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
|
|
||||||
> .cap_tasks~
|
|
||||||
fi
|
fi
|
||||||
compadd `cat .cap_tasks~`
|
compadd `cat ${_cap_task_cache_file}`
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
compctl -K _cap cap
|
compdef _cap cap
|
||||||
|
|
Loading…
Reference in a new issue