-
-
Save ysugimoto/360a386ff2a326aec0d58de9ec8e43ea to your computer and use it in GitHub Desktop.
Artisan task selector-runner ( Depend peco )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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