Skip to content

Instantly share code, notes, and snippets.

@zev
Created August 19, 2010 10:14
Show Gist options
  • Save zev/537535 to your computer and use it in GitHub Desktop.
Save zev/537535 to your computer and use it in GitHub Desktop.
# get the apps
#ey environments --all | grep -E "^\w"
# get the environments
#ey environments --all | grep -E "^\s+\w" | awk '{print $1}'
_ey_does_ssh_list_need_generating () {
if [ ! -f ~/.ey_ssh_lists ]; then return 0;
else
yesterday=$(date +%s -d yesterday)
accurate=$(stat -c%Y ~/.ey_ssh_lists)
return $(expr $accurate '>' $yesterday)
fi
}
_ey () {
if (( CURRENT == 2 )); then
if [[ -z $ey_commands ]] ; then
ey_commands=$(ey help | grep -E '^ +ey [a-z]+' | cut -d " " -f 4 | uniq)
fi
# This seems unnecessary, but if I try to set gem_commands to an array, it falls over.
typeset -a ey_command_array
ey_command_array=($(echo $ey_commands))
compadd $ey_command_array
else
if [[ $words[2] == recipes ]] ; then
compadd "apply" "upload" "download"
fi
if [[ $words[2] == web ]] ; then
compadd "enable" "disable"
fi
if [[ $words[2] == ssh ]] ; then
if _ey_does_ssh_list_need_generating ; then
echo "\nGenerating .ey_ssh_lists..." > /dev/stderr
ey ssh --list -e testdb > ~/.ey_ssh_lists
fi
if [[ $words[3] == -s ]] ; then
compadd `cat ~/.ey_ssh_lists`
else
compadd "--all" "--app_servers" "--db_servers" "--db_master" "--db_slaves" "--utilities" "-s" "--list"
fi
fi
fi
}
compdef _ey ey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment