Last active
August 29, 2015 13:56
-
-
Save xphere/9205529 to your computer and use it in GitHub Desktop.
Bash function for Symfony console
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
sf() { | |
local DIR | |
pushd . > /dev/null 2>&1 | |
while ! git exec test -x app/console; do | |
if [ $PWD = "/" ]; then | |
popd > /dev/null 2>&1 | |
echo "Can't find a suitable Symfony application" 1>&2 | |
return 1 | |
fi | |
DIR=$(git rev-parse --show-toplevel 2> /dev/null) | |
if [[ $DIR ]]; then | |
cd "$DIR" | |
fi | |
cd .. | |
done | |
git exec app/console "$@" | |
EXITCODE=$? | |
popd > /dev/null 2>&1 | |
if which notify-send > /dev/null 2>&1 && [[ -n "$@" ]] && ! [[ "$@" =~ "-h" ]]; then | |
MESSAGE=$([[ $EXITCODE = 0 ]] && echo "finished" || echo "failed with error $EXITCODE") | |
notify-send "Symfony Console" "$1 $MESSAGE" | |
fi | |
return "$EXITCODE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment