Skip to content

Instantly share code, notes, and snippets.

@mul14
Last active December 18, 2016 11:10
Show Gist options
  • Save mul14/8e9941dab7149d23238977c0814ecfa5 to your computer and use it in GitHub Desktop.
Save mul14/8e9941dab7149d23238977c0814ecfa5 to your computer and use it in GitHub Desktop.
Laravel Homesteak
#!/usr/bin/env sh
# Laravel Homestead v3 and v4 are sucks!
# They removes useful commands like "homestead up" or "homestead ssh" from v2.
# Here is "homesteak", simple script to bring back those commands.
# Set composer directory.
if [ ! $COMPOSER_HOME = '' ]; then
COMPOSER_DIRECTORY="$COMPOSER_HOME";
elif [ ! $XDG_CONFIG_HOME = '' ]; then
COMPOSER_DIRECTORY="$XDG_CONFIG_HOME/composer";
elif [ -d $HOME/config/composer ]; then
COMPOSER_DIRECTORY="$HOME/config/composer";
else
COMPOSER_DIRECTORY="$HOME/.composer";
fi
# Check if Homestead already installed.
HOMESTEAD_DIRECTORY="$COMPOSER_DIRECTORY/vendor/laravel/homestead";
if [ ! -d "$HOMESTEAD_DIRECTORY" ]; then
echo "Laravel Homestead is not installed.";
exit 1;
fi
# Check if user provide command or not.
if [ $# -eq 0 ]; then
echo "Homesteak command is required."
echo "Available commands: \"up down halt suspend destroy ssh status version\"";
echo "Usage example: homesteak version"
exit 1;
fi
CURRENT_WORKING_DIRECTORY=$(pwd)
array=('up' 'down' 'halt' 'suspend' 'destroy' 'ssh' 'status' 'version')
for i in "${array[@]}"
do
if [ $i = "$1" ]; then
# Command alias
if [ $1 = 'down' ]; then
COMMAND='halt'
else
COMMAND="$1"
fi
cd "$HOMESTEAD_DIRECTORY";
vagrant "$COMMAND";
cd "$CURRENT_WORKING_DIRECTORY";
exit 0;
fi
done
echo "Homesteak command \"$1\" is not available.";
exit 1;
@mul14
Copy link
Author

mul14 commented Dec 18, 2016

Laravel Homesteak

Overview

Laravel Homestead v3 and v4 are sucks!
Taylor removes useful commands like homestead up or homestead ssh from v2.
Here is "homesteak", simple script to bring back those commands.

Installation

Easy way

Just copy & paste this to your terminal

curl -sfLS https://gist.github.com/mul14/8e9941dab7149d23238977c0814ecfa5/raw/43719a19c46a44063cd581c3ab380cba4fdcf6c6/homesteak.sh > /usr/local/bin/homesteak && chmod +x /usr/local/bin/homesteak

Manual

Put the script to your $PATH. For example to /usr/local/bin/homesteak. And don't forget to make it executable by using chmod +x /usr/local/bin/homesteak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment