Skip to content

Instantly share code, notes, and snippets.

@ysugimoto
Last active Jul 12, 2016
Embed
What would you like to do?
Artisan task selector-runner ( Depend peco )
#!/bin/sh
# Artisan ( Laravel's CLI tool ) find-up, selectable runner
# @depend
# peco - https://github.com/peco/peco
PHP=`which php`
CWD=`pwd`
ARTISAN="artisan"
COMMAND=
while [ "${CWD}" != "/" ]; do
if [ -f "${CWD}/${ARTISAN}" ]; then
COMMAND="${CWD}/${ARTISAN}"
break
else
CWD=`dirname ${CWD}`
fi
done
if [ "${COMMAND}" = "" ]; then
echo "artisan command not found."
exit
fi
while :; do
TASK=`${PHP} ${COMMAND} list | tail -n +17 | peco`
DESC=`echo ${TASK} | awk '{print $2}'`
if [ "${DESC}" != "" ]; then
TASK=`echo ${TASK} | awk '{print $1}'`
echo "${PHP} ${COMMAND} ${TASK} $@"
${PHP} ${COMMAND} ${TASK} $@
break
else
echo "Select task name, not group:"
sleep 1s
fi
done
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment