Created
January 25, 2016 10:47
-
-
Save wiyarmir/e9e92e4be404f13c8c24 to your computer and use it in GitHub Desktop.
Script to configure automatically an alias to Symfony console with version 3.0 and earlies
This file contains 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/bash | |
# Comment this if you won't display the symfony version and environment | |
export SYMFONYRC_DISPLAY_VERSION=1 | |
# Execute 'sfenv' to change the default environment | |
function sfenv() | |
{ | |
case $1 in | |
prod|dev|test ) | |
export SYMFONY_ENV=$1 | |
echo "Symfony environment changed to $1"; | |
;; | |
esac | |
} | |
# Create a 'console' alias command to the real console command. It works with | |
# Symfony 3.0 and earlier versions. | |
function __sf_console() | |
{ | |
local version | |
if [[ -e "vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php" ]]; | |
then | |
if [[ -e "bin/console" ]]; | |
then | |
alias console=bin/console | |
elif [[ -e "app/console" ]]; then | |
alias console=app/console | |
fi | |
if [[ -n "$SYMFONYRC_DISPLAY_VERSION" ]]; | |
then | |
version=$(console --version --ansi 2> /dev/null) | |
if [[ $? -eq 0 ]]; | |
then | |
echo $version | |
fi | |
fi | |
elif alias console >& /dev/null; | |
then | |
unalias console | |
fi | |
} | |
function __sf_init() | |
{ | |
if [[ ! "$PROMPT_COMMAND" =~ "__sf_console" ]]; | |
then | |
export PROMPT_COMMAND="${PROMPT_COMMAND};__sf_console" | |
fi | |
} | |
__sf_init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment