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
16ae4e12
Commit
16ae4e12
authored
Jan 26, 2014
by
Pablo Cantero
Browse files
Adds support capistrano multistage completion
parent
e2838f75
Changes
2
Hide whitespace changes
Inline
Side-by-side
plugins/capistrano/_capistrano
View file @
16ae4e12
#compdef cap
#compdef
xcap
cap
#autoload
#autoload
if [[ -f config/deploy.rb || -f Capfile ]]; then
# Added `xcap` because `cap` is a reserved word. `cap` completion doesn't work.
if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then
# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
echo "\nGenerating .cap_tasks~..." > /dev/stderr
cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
local curcontext="$curcontext" state line ret=1
local -a _configs
_arguments -C \
'1: :->cmds' \
'2:: :->args' && ret=0
_cap_tasks() {
if [[ -f config/deploy.rb || -f Capfile ]]; then
if [[ ! -f .cap_tasks~ ]]; then
xcap -v --tasks | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~
fi
OLD_IFS=$IFS
IFS=$'\n'
_values 'cap commands' $(< .cap_tasks~)
IFS=$OLD_IFS
# zmodload zsh/mapfile
# _values ${(f)mapfile[.cap_tasks~]}
fi
fi
compadd `cat .cap_tasks~`
}
fi
_cap_stages() {
compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g)
}
case $state in
cmds)
# check if it uses multistage
if [[ -d config/deploy ]]; then
_cap_stages
else
_cap_tasks
fi
ret=0
;;
args)
_cap_tasks
ret=0
;;
esac
return ret
plugins/capistrano/capistrano.plugin.zsh
0 → 100644
View file @
16ae4e12
# Added `xcap` because `cap` is a reserved word. `cap` completion doesn't work.
# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
func xcap
()
{
if
[
-f
Gemfile
]
then
bundle
exec
cap
$*
else
cap
$*
fi
}
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