Skip to content

Instantly share code, notes, and snippets.

@libero18
Created July 16, 2014 02:06
Show Gist options
  • Save libero18/de69679943b2492f830c to your computer and use it in GitHub Desktop.
Save libero18/de69679943b2492f830c to your computer and use it in GitHub Desktop.
boot2dockerコマンドの手抜き補完と環境変数($DOCKER_HOST)の自動設定
## boot2docker
if command -v boot2docker &>/dev/null; then
if [ "$(boot2docker status 2> /dev/null)" = 'running' ]; then
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375
fi
compdef _boot2dockercmd boot2docker_wrapper
function _boot2dockercmd {
local -a cmds
if (( CURRENT == 2 ));then
cmds=('init' 'destroy' 'up' 'start' 'save' 'stop' 'download' 'pause' 'restart' 'status' 'info' 'delete' 'ssh')
_describe -t commands "subcommand" cmds
else
_files
fi
return 1;
}
function boot2docker_wrapper() {
if [ $1 = 'up' ]; then
shift
\boot2docker up $@ && export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375
else
\boot2docker $@
fi
}
alias boot2docker=boot2docker_wrapper
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment