Skip to content

Instantly share code, notes, and snippets.

@xphere
Last active August 29, 2015 13:56
Show Gist options
  • Save xphere/9205529 to your computer and use it in GitHub Desktop.
Save xphere/9205529 to your computer and use it in GitHub Desktop.
Bash function for Symfony console
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