Skip to content

Instantly share code, notes, and snippets.

@skatsuta
Last active January 5, 2021 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save skatsuta/392d3cd251dd468b75c7 to your computer and use it in GitHub Desktop.
Save skatsuta/392d3cd251dd468b75c7 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
# fetch the first running machine name
local machine=$(docker-machine ls | grep "Running" | head -n 1 | awk '{ print $1 }')
if [ "$machine" != "" ]; then
eval "$(docker-machine env $machine)"
fi
fi
@aclowkey
Copy link

aclowkey commented Jul 3, 2017

Any windows equivalent ?

@kozak127
Copy link

kozak127 commented Jan 5, 2021

Thanks, this was driving me crazy!

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