Skip to content

Instantly share code, notes, and snippets.

@diegovillacis10
Forked from skatsuta/docker-machine.sh
Last active June 17, 2016 15:17
Show Gist options
  • Save diegovillacis10/77cbd02ee3c1d971f7681e012333af2e to your computer and use it in GitHub Desktop.
Save diegovillacis10/77cbd02ee3c1d971f7681e012333af2e to your computer and use it in GitHub Desktop.
Tired of running `eval "$(docker-machine env host)"` every time? Just paste this in .bashrc / .zshrc. This script automatically sets environment variables for one of running host machines in Docker Machine.
# check if `docker-machine` command exists
if command -v docker-machine > /dev/null; then
local machine_name=default
local machine_status=$(docker-machine status $machine_name)
if [ "$machine_status" = "Running" ]; then
eval "$(docker-machine env $machine_name)"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment