Skip to content

Instantly share code, notes, and snippets.

@dontfreakout
Created January 22, 2020 16:39
Show Gist options
  • Save dontfreakout/8072de95c8eedc802d64b6f06abfd25d to your computer and use it in GitHub Desktop.
Save dontfreakout/8072de95c8eedc802d64b6f06abfd25d to your computer and use it in GitHub Desktop.
Shell shortcuts for Homestead or any Vagrant box
function homestead() {
( cd ~/Homestead && vagrant $* )
}
export -f homestead
## SSH to box and cd to same directory as current dir on local machine. If machine is offline, start it up before ssh to it
function homessh() {
if homestead status --machine-readable | grep state,running > /dev/null 2>&1; then
homestead ssh -- -t "cd code/${PWD##*/}; /bin/bash"
else
echo "Machine down. Starting it up before loging in..."
homestead up && homestead ssh -- -t "cd code/${PWD##*/}; /bin/bash"
fi
}
export -f homessh
alias homeup='homestead up'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment